diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 08a6df7b665..677d0ce8a8b 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -7,6 +7,8 @@ body: ## Guidelines Please make sure you are running the latest version of Skript on a supported server platform and version. Try to make sure there are no issues of this same problem currently open either. + As of the release of Skript 2.10, the oldest supported version has been raised to 1.19.4. + Any issues created for versions older than 1.19.4 will not be looked into or fixed unless the issue persists on supported versions. - type: textarea attributes: label: Skript/Server Version diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5b930003730..16900d59a6f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,12 @@ version: 2 updates: + - package-ecosystem: "gitsubmodule" + target-branch: "dev/patch" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" - package-ecosystem: "github-actions" target-branch: "dev/patch" directory: "/" diff --git a/src/main/java/ch/njol/skript/PatcherTool.java b/src/main/java/ch/njol/skript/PatcherTool.java index 6b2355fdaf9..66062ae1769 100644 --- a/src/main/java/ch/njol/skript/PatcherTool.java +++ b/src/main/java/ch/njol/skript/PatcherTool.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/ServerPlatform.java b/src/main/java/ch/njol/skript/ServerPlatform.java index 8313476883e..97fbc66e055 100644 --- a/src/main/java/ch/njol/skript/ServerPlatform.java +++ b/src/main/java/ch/njol/skript/ServerPlatform.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; /** diff --git a/src/main/java/ch/njol/skript/Skript.java b/src/main/java/ch/njol/skript/Skript.java index 8bd3a557a35..e425cb19c4e 100644 --- a/src/main/java/ch/njol/skript/Skript.java +++ b/src/main/java/ch/njol/skript/Skript.java @@ -62,7 +62,6 @@ import ch.njol.skript.variables.Variables; import ch.njol.util.Closeable; import ch.njol.util.Kleenean; -import ch.njol.util.NullableChecker; import ch.njol.util.StringUtils; import ch.njol.util.coll.iterator.CheckedIterator; import ch.njol.util.coll.iterator.EnumerationIterable; @@ -70,6 +69,7 @@ import com.google.common.collect.Lists; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.bstats.bukkit.Metrics; import org.bstats.charts.SimplePie; import org.bukkit.*; @@ -87,17 +87,23 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Unmodifiable; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; import org.junit.After; import org.junit.runner.JUnitCore; import org.junit.runner.Result; +import org.skriptlang.skript.bukkit.registration.BukkitRegistryKeys; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; import org.junit.runner.notification.Failure; import org.skriptlang.skript.bukkit.SkriptMetrics; import org.skriptlang.skript.bukkit.breeding.BreedingModule; import org.skriptlang.skript.bukkit.displays.DisplayModule; +import org.skriptlang.skript.bukkit.furnace.FurnaceModule; import org.skriptlang.skript.bukkit.fishing.FishingModule; import org.skriptlang.skript.bukkit.input.InputModule; +import org.skriptlang.skript.bukkit.loottables.LootTableModule; import org.skriptlang.skript.lang.comparator.Comparator; import org.skriptlang.skript.lang.comparator.Comparators; import org.skriptlang.skript.lang.converter.Converter; @@ -107,6 +113,9 @@ import org.skriptlang.skript.lang.script.Script; import org.skriptlang.skript.lang.structure.Structure; import org.skriptlang.skript.lang.structure.StructureInfo; +import org.skriptlang.skript.registration.SyntaxOrigin; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.registration.SyntaxInfo; import java.io.File; import java.io.IOException; @@ -141,6 +150,8 @@ import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; @@ -179,14 +190,24 @@ public final class Skript extends JavaPlugin implements Listener { @Nullable private static Skript instance = null; + static org.skriptlang.skript.@UnknownNullability Skript skript = null; + private static org.skriptlang.skript.@UnknownNullability Skript unmodifiableSkript = null; + private static boolean disabled = false; private static boolean partDisabled = false; public static Skript getInstance() { - final Skript i = instance; - if (i == null) + if (instance == null) throw new IllegalStateException(); - return i; + return instance; + } + + @ApiStatus.Experimental + public static org.skriptlang.skript.Skript instance() { + if (unmodifiableSkript == null) { + throw new SkriptAPIException("Skript is still initializing"); + } + return unmodifiableSkript; } /** @@ -207,7 +228,6 @@ public Skript() throws IllegalStateException { /** * Check minecraft version and assign it to minecraftVersion field * This method is created to update MC version before onEnable method - * To fix {@link Utils#HEX_SUPPORTED} being assigned before minecraftVersion is properly assigned */ public static void updateMinecraftVersion() { String bukkitV = Bukkit.getBukkitVersion(); @@ -392,8 +412,6 @@ public void onEnable() { } catch (Exception e) { Skript.exception(e, "Update checker could not be initialized."); } - experimentRegistry = new ExperimentRegistry(this); - Feature.registerAll(getAddonInstance(), experimentRegistry); if (!getDataFolder().isDirectory()) getDataFolder().mkdirs(); @@ -468,9 +486,17 @@ public void onEnable() { } } - // initialize the Skript addon instance + // initialize the modern Skript instance + skript = org.skriptlang.skript.Skript.of(getClass(), getName()); + unmodifiableSkript = skript.unmodifiableView(); + skript.localizer().setSourceDirectories("lang", + getDataFolder().getAbsolutePath() + "lang"); + // initialize the old Skript SkriptAddon instance getAddonInstance(); + experimentRegistry = new ExperimentRegistry(this); + Feature.registerAll(getAddonInstance(), experimentRegistry); + // Load classes which are always safe to use new JavaClasses(); // These may be needed in configuration @@ -549,6 +575,8 @@ public void onEnable() { BreedingModule.load(); DisplayModule.load(); InputModule.load(); + FurnaceModule.load(); + LootTableModule.load(); } catch (final Exception e) { exception(e, "Could not load required .class files: " + e.getLocalizedMessage()); setEnabled(false); @@ -616,7 +644,6 @@ public void run() { stopAcceptingRegistrations(); - Documentation.generate(); // TODO move to test classes? // Variable loading @@ -769,7 +796,10 @@ protected void afterErrors() { EffObjectives.fail(); info("Collecting results to " + TestMode.RESULTS_FILE); - String results = new Gson().toJson(TestTracker.collectResults()); + String results = new GsonBuilder() + .setPrettyPrinting() // Easier to read lines + .disableHtmlEscaping() // Fixes issue with "'" character in test strings going unicode + .create().toJson(TestTracker.collectResults()); try { Files.write(TestMode.RESULTS_FILE, results.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { @@ -1223,7 +1253,6 @@ private boolean isServerRunning() { private void beforeDisable() { partDisabled = true; EvtSkript.onSkriptStop(); // TODO [code style] warn user about delays in Skript stop events - ScriptLoader.unloadScripts(ScriptLoader.getLoadedScripts()); } @@ -1335,194 +1364,231 @@ public static void checkAcceptRegistrations() { private static void stopAcceptingRegistrations() { Converters.createChainedConverters(); - acceptRegistrations = false; - Classes.onRegistrationsStop(); } // ================ ADDONS ================ - private final static HashMap addons = new HashMap<>(); + @Deprecated + private static final Set addons = new HashSet<>(); /** * Registers an addon to Skript. This is currently not required for addons to work, but the returned {@link SkriptAddon} provides useful methods for registering syntax elements * and adding new strings to Skript's localization system (e.g. the required "types.[type]" strings for registered classes). - * - * @param p The plugin + * + * @param plugin The plugin */ - public static SkriptAddon registerAddon(final JavaPlugin p) { + public static SkriptAddon registerAddon(JavaPlugin plugin) { checkAcceptRegistrations(); - if (addons.containsKey(p.getName())) - throw new IllegalArgumentException("The plugin " + p.getName() + " is already registered"); - final SkriptAddon addon = new SkriptAddon(p); - addons.put(p.getName(), addon); + SkriptAddon addon = new SkriptAddon(plugin); + addons.add(addon); return addon; } - @Nullable - public static SkriptAddon getAddon(final JavaPlugin p) { - return addons.get(p.getName()); + public static @Nullable SkriptAddon getAddon(JavaPlugin plugin) { + if (plugin == Skript.getInstance()) { + return Skript.getAddonInstance(); + } + for (SkriptAddon addon : getAddons()) { + if (addon.plugin == plugin) { + return addon; + } + } + return null; } - @Nullable - public static SkriptAddon getAddon(final String name) { - return addons.get(name); + public static @Nullable SkriptAddon getAddon(String name) { + if (name.equals(Skript.getInstance().getName())) { + return Skript.getAddonInstance(); + } + for (SkriptAddon addon : getAddons()) { + if (addon.getName().equals(name)) { + return addon; + } + } + return null; } - @SuppressWarnings("null") - public static Collection getAddons() { - return Collections.unmodifiableCollection(addons.values()); + public static @Unmodifiable Collection getAddons() { + Set addons = new HashSet<>(Skript.addons); + addons.addAll(instance().addons().stream() + .filter(addon -> addons.stream().noneMatch(oldAddon -> oldAddon.name().equals(addon.name()))) + .map(SkriptAddon::fromModern) + .collect(Collectors.toSet()) + ); + return Collections.unmodifiableCollection(addons); } - @Nullable - private static SkriptAddon addon; + @Deprecated + private static @Nullable SkriptAddon addon; /** * @return A {@link SkriptAddon} representing Skript. */ public static SkriptAddon getAddonInstance() { if (addon == null) { - addon = new SkriptAddon(Skript.getInstance()); - addon.setLanguageFileDirectory("lang"); + addon = SkriptAddon.fromModern(instance()); } return addon; } // ================ CONDITIONS & EFFECTS & SECTIONS ================ - private static final List> conditions = new ArrayList<>(50); - private static final List> effects = new ArrayList<>(50); - private static final List> statements = new ArrayList<>(100); - private static final List> sections = new ArrayList<>(50); + private static final class BukkitOrigin implements SyntaxOrigin { - public static Collection> getStatements() { - return statements; - } + private final String name; - public static Collection> getEffects() { - return effects; - } + private BukkitOrigin(Plugin plugin) { + this.name = plugin.getName(); + } - public static Collection> getSections() { - return sections; - } + @Override + public String name() { + return name; + } - // ================ CONDITIONS ================ - public static Collection> getConditions() { - return conditions; } - private final static int[] conditionTypesStartIndices = new int[ConditionType.values().length]; + private static SyntaxOrigin getSyntaxOrigin(JavaPlugin plugin) { + SkriptAddon addon = getAddon(plugin); + if (addon != null) { + return SyntaxOrigin.of(addon); + } + return new BukkitOrigin(plugin); + } /** - * registers a {@link Condition}. - * - * @param condition The condition's class + * Registers a {@link Condition}. + * + * @param conditionClass The condition's class * @param patterns Skript patterns to match this condition */ - public static void registerCondition(Class condition, String... patterns) throws IllegalArgumentException { - registerCondition(condition, ConditionType.COMBINED, patterns); + public static void registerCondition(Class conditionClass, String... patterns) throws IllegalArgumentException { + registerCondition(conditionClass, ConditionType.COMBINED, patterns); } /** - * registers a {@link Condition}. - * - * @param condition The condition's class - * @param type The conditions {@link ConditionType type}. This is used to determine in which order to try to parse conditions. + * Registers a {@link Condition}. + * + * @param conditionClass The condition's class + * @param type The type of condition which affects its priority in the parsing search * @param patterns Skript patterns to match this condition */ - public static void registerCondition(Class condition, ConditionType type, String... patterns) throws IllegalArgumentException { + public static void registerCondition(Class conditionClass, ConditionType type, String... patterns) throws IllegalArgumentException { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - final SyntaxElementInfo info = new SyntaxElementInfo<>(patterns, condition, originClassPath); - conditions.add(conditionTypesStartIndices[type.ordinal()], info); - statements.add(conditionTypesStartIndices[type.ordinal()], info); - for (int i = type.ordinal(); i < ConditionType.values().length; i++) - conditionTypesStartIndices[i]++; + skript.syntaxRegistry().register(SyntaxRegistry.CONDITION, SyntaxInfo.builder(conditionClass) + .priority(type.priority()) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(conditionClass))) + .addPatterns(patterns) + .build() + ); } /** * Registers an {@link Effect}. - * - * @param effect The effect's class + * + * @param effectClass The effect's class * @param patterns Skript patterns to match this effect */ - public static void registerEffect(final Class effect, final String... patterns) throws IllegalArgumentException { + public static void registerEffect(Class effectClass, String... patterns) throws IllegalArgumentException { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - final SyntaxElementInfo info = new SyntaxElementInfo<>(patterns, effect, originClassPath); - effects.add(info); - statements.add(info); + skript.syntaxRegistry().register(SyntaxRegistry.EFFECT, SyntaxInfo.builder(effectClass) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(effectClass))) + .addPatterns(patterns) + .build() + ); } /** * Registers a {@link Section}. * - * @param section The section's class + * @param sectionClass The section's class * @param patterns Skript patterns to match this section * @see Section */ - public static void registerSection(Class section, String... patterns) throws IllegalArgumentException { + public static void registerSection(Class sectionClass, String... patterns) throws IllegalArgumentException { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - SyntaxElementInfo info = new SyntaxElementInfo<>(patterns, section, originClassPath); - sections.add(info); + skript.syntaxRegistry().register(SyntaxRegistry.SECTION, SyntaxInfo.builder(sectionClass) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(sectionClass))) + .addPatterns(patterns) + .build() + ); } - // ================ EXPRESSIONS ================ + public static @Unmodifiable Collection> getStatements() { + return instance().syntaxRegistry() + .syntaxes(SyntaxRegistry.STATEMENT).stream() + .map(SyntaxElementInfo::, Statement>fromModern) + .collect(Collectors.toUnmodifiableList()); + } - private final static List> expressions = new ArrayList<>(100); + public static @Unmodifiable Collection> getConditions() { + return instance().syntaxRegistry() + .syntaxes(SyntaxRegistry.CONDITION).stream() + .map(SyntaxElementInfo::, Condition>fromModern) + .collect(Collectors.toUnmodifiableList()); + } + + public static @Unmodifiable Collection> getEffects() { + return instance().syntaxRegistry() + .syntaxes(SyntaxRegistry.EFFECT).stream() + .map(SyntaxElementInfo::, Effect>fromModern) + .collect(Collectors.toUnmodifiableList()); + } + + public static @Unmodifiable Collection> getSections() { + return instance().syntaxRegistry() + .syntaxes(SyntaxRegistry.SECTION).stream() + .map(SyntaxElementInfo::, Section>fromModern) + .collect(Collectors.toUnmodifiableList()); + } - private final static int[] expressionTypesStartIndices = new int[ExpressionType.values().length]; + // ================ EXPRESSIONS ================ /** * Registers an expression. - * - * @param c The expression's class + * + * @param expressionType The expression's class * @param returnType The superclass of all values returned by the expression * @param type The expression's {@link ExpressionType type}. This is used to determine in which order to try to parse expressions. * @param patterns Skript patterns that match this expression * @throws IllegalArgumentException if returnType is not a normal class */ - public static , T> void registerExpression(final Class c, final Class returnType, final ExpressionType type, final String... patterns) throws IllegalArgumentException { + public static , T> void registerExpression( + Class expressionType, Class returnType, ExpressionType type, String... patterns + ) throws IllegalArgumentException { checkAcceptRegistrations(); - if (returnType.isAnnotation() || returnType.isArray() || returnType.isPrimitive()) - throw new IllegalArgumentException("returnType must be a normal type"); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - final ExpressionInfo info = new ExpressionInfo<>(patterns, returnType, c, originClassPath, type); - expressions.add(expressionTypesStartIndices[type.ordinal()], info); - for (int i = type.ordinal(); i < ExpressionType.values().length; i++) { - expressionTypesStartIndices[i]++; - } + skript.syntaxRegistry().register(SyntaxRegistry.EXPRESSION, SyntaxInfo.Expression.builder(expressionType, returnType) + .priority(type.priority()) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(expressionType))) + .addPatterns(patterns) + .build() + ); } - @SuppressWarnings("null") public static Iterator> getExpressions() { - return expressions.iterator(); - } - - public static Iterator> getExpressions(final Class... returnTypes) { - return new CheckedIterator<>(getExpressions(), new NullableChecker>() { - @Override - public boolean check(final @Nullable ExpressionInfo i) { - if (i == null || i.returnType == Object.class) + List> list = new ArrayList<>(); + for (SyntaxInfo.Expression info : instance().syntaxRegistry().syntaxes(SyntaxRegistry.EXPRESSION)) + list.add((ExpressionInfo) SyntaxElementInfo.fromModern(info)); + return list.iterator(); + } + + public static Iterator> getExpressions(Class... returnTypes) { + return new CheckedIterator<>(getExpressions(), info -> { + if (info == null || info.returnType == Object.class) + return true; + for (Class returnType : returnTypes) { + assert returnType != null; + if (Converters.converterExists(info.returnType, returnType)) return true; - for (final Class returnType : returnTypes) { - assert returnType != null; - if (Converters.converterExists(i.returnType, returnType)) - return true; - } - return false; } + return false; }); } // ================ EVENTS ================ - private static final List> events = new ArrayList<>(50); - private static final List> structures = new ArrayList<>(10); - /** * Registers an event. * @@ -1542,51 +1608,66 @@ public static SkriptEventInfo registerEvent(String na * Registers an event. * * @param name The name of the event, used for error messages - * @param c The event's class + * @param eventClass The event's class * @param events The Bukkit events this event applies to * @param patterns Skript patterns to match this event * @return A SkriptEventInfo representing the registered event. Used to generate Skript's documentation. */ - public static SkriptEventInfo registerEvent(String name, Class c, Class[] events, String... patterns) { + @SuppressWarnings("ConstantConditions") // caused by bad array annotations + public static SkriptEventInfo registerEvent( + String name, Class eventClass, Class[] events, String... patterns + ) { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - - String[] transformedPatterns = new String[patterns.length]; for (int i = 0; i < patterns.length; i++) - transformedPatterns[i] = SkriptEvent.fixPattern(patterns[i]); - - SkriptEventInfo r = new SkriptEventInfo<>(name, transformedPatterns, c, originClassPath, events); - Skript.events.add(r); - return r; + patterns[i] = BukkitSyntaxInfos.fixPattern(patterns[i]); + var legacy = new SkriptEventInfo.ModernSkriptEventInfo<>(name, patterns, eventClass, "", events); + skript.syntaxRegistry().register(BukkitRegistryKeys.EVENT, legacy); + return legacy; } - public static void registerStructure(Class c, String... patterns) { + public static void registerStructure(Class structureClass, String... patterns) { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - StructureInfo structureInfo = new StructureInfo<>(patterns, c, originClassPath); - structures.add(structureInfo); + skript.syntaxRegistry().register(SyntaxRegistry.STRUCTURE, SyntaxInfo.Structure.builder(structureClass) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(structureClass))) + .addPatterns(patterns) + .build() + ); } - public static void registerSimpleStructure(Class c, String... patterns) { + public static void registerSimpleStructure(Class structureClass, String... patterns) { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - StructureInfo structureInfo = new StructureInfo<>(patterns, c, originClassPath, true); - structures.add(structureInfo); + skript.syntaxRegistry().register(SyntaxRegistry.STRUCTURE, SyntaxInfo.Structure.builder(structureClass) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(structureClass))) + .addPatterns(patterns) + .nodeType(SyntaxInfo.Structure.NodeType.SIMPLE) + .build() + ); } - public static void registerStructure(Class c, EntryValidator entryValidator, String... patterns) { + public static void registerStructure( + Class structureClass, EntryValidator entryValidator, String... patterns + ) { checkAcceptRegistrations(); - String originClassPath = Thread.currentThread().getStackTrace()[2].getClassName(); - StructureInfo structureInfo = new StructureInfo<>(patterns, c, originClassPath, entryValidator); - structures.add(structureInfo); + skript.syntaxRegistry().register(SyntaxRegistry.STRUCTURE, SyntaxInfo.Structure.builder(structureClass) + .origin(getSyntaxOrigin(JavaPlugin.getProvidingPlugin(structureClass))) + .addPatterns(patterns) + .entryValidator(entryValidator) + .build() + ); } - public static Collection> getEvents() { - return events; + public static @Unmodifiable Collection> getEvents() { + return instance().syntaxRegistry() + .syntaxes(BukkitRegistryKeys.EVENT).stream() + .map(SyntaxElementInfo::, SkriptEvent>fromModern) + .collect(Collectors.toUnmodifiableList()); } - public static List> getStructures() { - return structures; + public static @Unmodifiable List> getStructures() { + return instance().syntaxRegistry() + .syntaxes(SyntaxRegistry.STRUCTURE).stream() + .map(SyntaxElementInfo::, Structure>fromModern) + .collect(Collectors.toUnmodifiableList()); } // ================ COMMANDS ================ @@ -1651,6 +1732,17 @@ public static void debug(final String info) { SkriptLogger.log(SkriptLogger.DEBUG, info); } + /** + * Sends a debug message with formatted objects if {@link #debug()} returns true. + * + * @param message The message to send + * @param objects The objects to format the message with + * @see String#formatted(Object...) + */ + public static void debug(String message, Object... objects) { + debug(message.formatted(objects)); + } + /** * @see SkriptLogger#log(Level, String) */ diff --git a/src/main/java/ch/njol/skript/SkriptAPIException.java b/src/main/java/ch/njol/skript/SkriptAPIException.java index a9cf43afc1c..25230f55fb6 100644 --- a/src/main/java/ch/njol/skript/SkriptAPIException.java +++ b/src/main/java/ch/njol/skript/SkriptAPIException.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; /** diff --git a/src/main/java/ch/njol/skript/SkriptAddon.java b/src/main/java/ch/njol/skript/SkriptAddon.java index 3a1cf894d35..f09bdcf4e5d 100644 --- a/src/main/java/ch/njol/skript/SkriptAddon.java +++ b/src/main/java/ch/njol/skript/SkriptAddon.java @@ -1,68 +1,61 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; import java.io.File; import java.io.IOException; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.Nullable; -import ch.njol.skript.localization.Language; import ch.njol.skript.util.Utils; import ch.njol.skript.util.Version; +import org.jetbrains.annotations.ApiStatus; +import org.skriptlang.skript.localization.Localizer; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Registry; /** * Utility class for Skript addons. Use {@link Skript#registerAddon(JavaPlugin)} to create a SkriptAddon instance for your plugin. */ -public final class SkriptAddon { +public final class SkriptAddon implements org.skriptlang.skript.addon.SkriptAddon { public final JavaPlugin plugin; public final Version version; private final String name; + private final org.skriptlang.skript.addon.SkriptAddon addon; + /** * Package-private constructor. Use {@link Skript#registerAddon(JavaPlugin)} to get a SkriptAddon for your plugin. - * - * @param p */ - SkriptAddon(final JavaPlugin p) { - plugin = p; - name = "" + p.getName(); - Version v; + SkriptAddon(JavaPlugin plugin) { + this(plugin, Skript.skript.registerAddon(plugin.getClass(), plugin.getName())); + } + + SkriptAddon(JavaPlugin plugin, org.skriptlang.skript.addon.SkriptAddon addon) { + this.addon = addon; + this.plugin = plugin; + this.name = plugin.getName(); + Version version; try { - v = new Version("" + p.getDescription().getVersion()); - } catch (final IllegalArgumentException e) { - final Matcher m = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?").matcher(p.getDescription().getVersion()); + version = new Version(plugin.getDescription().getVersion()); + } catch (IllegalArgumentException e) { + final Matcher m = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?").matcher(plugin.getDescription().getVersion()); if (!m.find()) - throw new IllegalArgumentException("The version of the plugin " + p.getName() + " does not contain any numbers: " + p.getDescription().getVersion()); - v = new Version(Utils.parseInt("" + m.group(1)), m.group(2) == null ? 0 : Utils.parseInt("" + m.group(2)), m.group(3) == null ? 0 : Utils.parseInt("" + m.group(3))); - Skript.warning("The plugin " + p.getName() + " uses a non-standard version syntax: '" + p.getDescription().getVersion() + "'. Skript will use " + v + " instead."); + throw new IllegalArgumentException("The version of the plugin " + name + " does not contain any numbers: " + plugin.getDescription().getVersion()); + version = new Version(Utils.parseInt(m.group(1)), m.group(2) == null ? 0 : Utils.parseInt(m.group(2)), m.group(3) == null ? 0 : Utils.parseInt(m.group(3))); + Skript.warning("The plugin " + name + " uses a non-standard version syntax: '" + plugin.getDescription().getVersion() + "'. Skript will use " + version + " instead."); } - version = v; + this.version = version; } @Override public final String toString() { - return name; + return getName(); } public String getName() { @@ -83,9 +76,6 @@ public SkriptAddon loadClasses(String basePackage, String... subPackages) throws return this; } - @Nullable - private String languageFileDirectory = null; - /** * Makes Skript load language files from the specified directory, e.g. "lang" or "skript lang" if you have a lang folder yourself. Localised files will be read from the * plugin's jar and the plugin's data folder, but the default English file is only taken from the jar and must exist! @@ -94,19 +84,13 @@ public SkriptAddon loadClasses(String basePackage, String... subPackages) throws * @return This SkriptAddon */ public SkriptAddon setLanguageFileDirectory(String directory) { - if (languageFileDirectory != null) - throw new IllegalStateException(); - directory = "" + directory.replace('\\', '/'); - if (directory.endsWith("/")) - directory = "" + directory.substring(0, directory.length() - 1); - languageFileDirectory = directory; - Language.loadDefault(this); + localizer().setSourceDirectories(directory, plugin.getDataFolder().getAbsolutePath() + directory); return this; } @Nullable public String getLanguageFileDirectory() { - return languageFileDirectory; + return localizer().languageFileDirectory(); } @Nullable @@ -126,4 +110,67 @@ public File getFile() { return file; } + // + // Modern SkriptAddon Compatibility + // + + @ApiStatus.Experimental + static SkriptAddon fromModern(org.skriptlang.skript.addon.SkriptAddon addon) { + return new SkriptAddon(JavaPlugin.getProvidingPlugin(addon.source()), addon); + } + + @Override + @ApiStatus.Experimental + public Class source() { + return addon.source(); + } + + @Override + @ApiStatus.Experimental + public String name() { + return addon.name(); + } + + @Override + @ApiStatus.Experimental + public > void storeRegistry(Class registryClass, R registry) { + addon.storeRegistry(registryClass, registry); + } + + @Override + @ApiStatus.Experimental + public void removeRegistry(Class> registryClass) { + addon.removeRegistry(registryClass); + } + + @Override + @ApiStatus.Experimental + public boolean hasRegistry(Class> registryClass) { + return addon.hasRegistry(registryClass); + } + + @Override + @ApiStatus.Experimental + public > R registry(Class registryClass) { + return addon.registry(registryClass); + } + + @Override + @ApiStatus.Experimental + public > R registry(Class registryClass, Supplier putIfAbsent) { + return addon.registry(registryClass, putIfAbsent); + } + + @Override + @ApiStatus.Experimental + public SyntaxRegistry syntaxRegistry() { + return addon.syntaxRegistry(); + } + + @Override + @ApiStatus.Experimental + public Localizer localizer() { + return addon.localizer(); + } + } diff --git a/src/main/java/ch/njol/skript/SkriptCommand.java b/src/main/java/ch/njol/skript/SkriptCommand.java index 248a79fd884..99d43150869 100644 --- a/src/main/java/ch/njol/skript/SkriptCommand.java +++ b/src/main/java/ch/njol/skript/SkriptCommand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; import ch.njol.skript.aliases.Aliases; @@ -32,12 +14,14 @@ import ch.njol.skript.test.runner.SkriptTestEvent; import ch.njol.skript.test.runner.TestMode; import ch.njol.skript.test.runner.TestTracker; +import ch.njol.skript.test.utils.TestResults; import ch.njol.skript.util.ExceptionUtils; import ch.njol.skript.util.FileUtils; import ch.njol.skript.util.SkriptColor; import ch.njol.skript.util.Utils; import ch.njol.util.OpenCloseable; import ch.njol.util.StringUtils; +import com.google.gson.GsonBuilder; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -50,7 +34,8 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; -import java.nio.file.Path; +import java.nio.file.Files; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -424,13 +409,15 @@ public boolean onCommand(CommandSender sender, Command command, String label, St return true; } } else { - scriptFile = TestMode.TEST_DIR.resolve( - Arrays.stream(args).skip(1).collect(Collectors.joining(" ")) + ".sk" - ).toFile(); - TestMode.lastTestFile = scriptFile; + if (args[1].equalsIgnoreCase("all")) { + scriptFile = TestMode.TEST_DIR.toFile(); + } else { + scriptFile = getScriptFromArgs(sender, args, TestMode.TEST_DIR.toFile()); + TestMode.lastTestFile = scriptFile; + } } - if (!scriptFile.exists()) { + if (scriptFile == null || !scriptFile.exists()) { Skript.error(sender, "Test script doesn't exist!"); return true; } @@ -443,10 +430,23 @@ public boolean onCommand(CommandSender sender, Command command, String label, St ScriptLoader.unloadScripts(ScriptLoader.getLoadedScripts()); // Get results and show them - String[] lines = TestTracker.collectResults().createReport().split("\n"); + TestResults testResults = TestTracker.collectResults(); + String[] lines = testResults.createReport().split("\n"); for (String line : lines) { Skript.info(sender, line); } + + // Log results to file + Skript.info(sender, "Collecting results to " + TestMode.RESULTS_FILE); + String results = new GsonBuilder() + .setPrettyPrinting() // Easier to read lines + .disableHtmlEscaping() // Fixes issue with "'" character in test strings going unicode + .create().toJson(testResults); + try { + Files.writeString(TestMode.RESULTS_FILE, results); + } catch (IOException e) { + Skript.exception(e, "Failed to write test results."); + } }) ); } else if (args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase("show")) { @@ -458,7 +458,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St ScriptLoader.getDisabledScripts().stream() .flatMap(file -> { if (file.isDirectory()) { - return Arrays.stream(file.listFiles()); + return getSubFiles(file).stream(); } return Arrays.stream(new File[]{file}); }) @@ -480,10 +480,27 @@ public boolean onCommand(CommandSender sender, Command command, String label, St private static final ArgsMessage m_invalid_script = new ArgsMessage(CONFIG_NODE + ".invalid script"); private static final ArgsMessage m_invalid_folder = new ArgsMessage(CONFIG_NODE + ".invalid folder"); - @Nullable - private static File getScriptFromArgs(CommandSender sender, String[] args) { + private static List getSubFiles(File file) { + List files = new ArrayList<>(); + if (file.isDirectory()) { + for (File listFile : file.listFiles(f -> !f.isHidden())) { + if (listFile.isDirectory()) { + files.addAll(getSubFiles(listFile)); + } else if (listFile.getName().endsWith(".sk")) { + files.add(listFile); + } + } + } + return files; + } + + private static @Nullable File getScriptFromArgs(CommandSender sender, String[] args) { + return getScriptFromArgs(sender, args, Skript.getInstance().getScriptsFolder()); + } + + private static @Nullable File getScriptFromArgs(CommandSender sender, String[] args, File directoryFile) { String script = StringUtils.join(args, " ", 1, args.length); - File f = getScriptFromName(script); + File f = getScriptFromName(script, directoryFile); if (f == null) { // Always allow '/' and '\' regardless of OS boolean directory = script.endsWith("/") || script.endsWith("\\") || script.endsWith(File.separator); @@ -493,8 +510,11 @@ private static File getScriptFromArgs(CommandSender sender, String[] args) { return f; } - @Nullable - public static File getScriptFromName(String script) { + public static @Nullable File getScriptFromName(String script) { + return getScriptFromName(script, Skript.getInstance().getScriptsFolder()); + } + + public static @Nullable File getScriptFromName(String script, File directoryFile) { if (script.endsWith("/") || script.endsWith("\\")) { // Always allow '/' and '\' regardless of OS script = script.replace('/', File.separatorChar).replace('\\', File.separatorChar); } else if (!StringUtils.endsWithIgnoreCase(script, ".sk")) { @@ -507,7 +527,7 @@ public static File getScriptFromName(String script) { if (script.startsWith(ScriptLoader.DISABLED_SCRIPT_PREFIX)) script = script.substring(ScriptLoader.DISABLED_SCRIPT_PREFIX_LENGTH); - File scriptFile = new File(Skript.getInstance().getScriptsFolder(), script); + File scriptFile = new File(directoryFile, script); if (!scriptFile.exists()) { scriptFile = new File(scriptFile.getParentFile(), ScriptLoader.DISABLED_SCRIPT_PREFIX + scriptFile.getName()); if (!scriptFile.exists()) { diff --git a/src/main/java/ch/njol/skript/SkriptCommandTabCompleter.java b/src/main/java/ch/njol/skript/SkriptCommandTabCompleter.java index 3d0fdf49267..009a0c76f10 100644 --- a/src/main/java/ch/njol/skript/SkriptCommandTabCompleter.java +++ b/src/main/java/ch/njol/skript/SkriptCommandTabCompleter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; import ch.njol.skript.doc.Documentation; @@ -46,8 +28,8 @@ public List onTabComplete(CommandSender sender, Command command, String if (args[0].equalsIgnoreCase("update") && args.length == 2) { options.add("check"); options.add("changes"); - } else if (args[0].matches("(?i)(reload|disable|enable)") && args.length >= 2) { - File scripts = Skript.getInstance().getScriptsFolder(); + } else if (args[0].matches("(?i)(reload|disable|enable|test)") && args.length >= 2) { + File scripts = TestMode.DEV_MODE ? TestMode.TEST_DIR.toFile() : Skript.getInstance().getScriptsFolder(); String scriptsPathString = scripts.toPath().toString(); int scriptsPathLength = scriptsPathString.length(); diff --git a/src/main/java/ch/njol/skript/SkriptConfig.java b/src/main/java/ch/njol/skript/SkriptConfig.java index 6cb2ab99ede..f846172b82c 100644 --- a/src/main/java/ch/njol/skript/SkriptConfig.java +++ b/src/main/java/ch/njol/skript/SkriptConfig.java @@ -4,7 +4,6 @@ import ch.njol.skript.config.EnumParser; import ch.njol.skript.config.Option; import ch.njol.skript.config.OptionSection; -import ch.njol.skript.config.SectionNode; import ch.njol.skript.hooks.Hook; import ch.njol.skript.hooks.VaultHook; import ch.njol.skript.hooks.regions.GriefPreventionHook; @@ -364,115 +363,75 @@ private static void userDisableHooks(Class> hookClass, boolean /** * This should only be used in special cases */ - @Nullable - public static Config getConfig() { + public static @Nullable Config getConfig() { return mainConfig; } - - // also used for reloading - static boolean load() { + + /** + * Reloads the main config file. + */ + static void load() { try { - final File oldConfigFile = new File(Skript.getInstance().getDataFolder(), "config.cfg"); - final File configFile = new File(Skript.getInstance().getDataFolder(), "config.sk"); - if (oldConfigFile.exists()) { - if (!configFile.exists()) { - oldConfigFile.renameTo(configFile); - Skript.info("[1.3] Renamed your 'config.cfg' to 'config.sk' to match the new format"); - } else { - Skript.error("Found both a new and an old config, ignoring the old one"); - } - } + File configFile = new File(Skript.getInstance().getDataFolder(), "config.sk"); + if (!configFile.exists()) { Skript.error("Config file 'config.sk' does not exist!"); - return false; + return; } if (!configFile.canRead()) { Skript.error("Config file 'config.sk' cannot be read!"); - return false; + return; } - - Config mc; + + Config mainConfig; try { - mc = new Config(configFile, false, false, ":"); - } catch (final IOException e) { - Skript.error("Could not load the main config: " + e.getLocalizedMessage()); - return false; + mainConfig = new Config(configFile, false, false, ":"); + } catch (IOException ex) { + Skript.exception(ex, "Could not load the main config"); + return; } - mainConfig = mc; + SkriptConfig.mainConfig = mainConfig; - String configVersion = mc.get(version.key); + String configVersion = mainConfig.get(version.key); if (configVersion == null || Skript.getVersion().compareTo(new Version(configVersion)) != 0) { - try { - final InputStream in = Skript.getInstance().getResource("config.sk"); - if (in == null) { + if (!mainConfig.getMainNode().isValid()) { + Skript.error("Your config is outdated, but cannot be updated because it contains errors."); + return; + } + + try (InputStream stream = Skript.getInstance().getResource("config.sk")) { + if (stream == null) { Skript.error("Your config is outdated, but Skript couldn't find the newest config in its jar."); - return false; - } - final Config newConfig = new Config(in, "Skript.jar/config.sk", false, false, ":"); - in.close(); - - boolean forceUpdate = false; - - if (mc.getMainNode().get("database") != null) { // old database layout - forceUpdate = true; - try { - final SectionNode oldDB = (SectionNode) mc.getMainNode().get("database"); - assert oldDB != null; - final SectionNode newDBs = (SectionNode) newConfig.getMainNode().get(databases.key); - assert newDBs != null; - final SectionNode newDB = (SectionNode) newDBs.get("database 1"); - assert newDB != null; - - newDB.setValues(oldDB); - - // '.db' was dynamically added before - final String file = newDB.getValue("file"); - assert file != null; - if (!file.endsWith(".db")) - newDB.set("file", file + ".db"); - - final SectionNode def = (SectionNode) newDBs.get("default"); - assert def != null; - def.set("backup interval", "" + mc.get("variables backup interval")); - } catch (final Exception e) { - Skript.error("An error occurred while trying to update the config's database section."); - Skript.error("You'll have to update the config yourself:"); - Skript.error("Open the new config.sk as well as the created backup, and move the 'database' section from the backup to the start of the 'databases' section"); - Skript.error("of the new config (i.e. the line 'databases:' should be directly above 'database:'), and add a tab in front of every line that you just copied."); - return false; - } + return; } - - if (newConfig.setValues(mc, version.key, databases.key) || forceUpdate) { // new config is different - final File bu = FileUtils.backup(configFile); - newConfig.getMainNode().set(version.key, Skript.getVersion().toString()); - if (mc.getMainNode().get(databases.key) != null) - newConfig.getMainNode().set(databases.key, mc.getMainNode().get(databases.key)); - mc = mainConfig = newConfig; - mc.save(configFile); - Skript.info("Your configuration has been updated to the latest version. A backup of your old config file has been created as " + bu.getName()); - } else { // only the version changed - mc.getMainNode().set(version.key, Skript.getVersion().toString()); - mc.save(configFile); + Config newConfig = new Config(stream, "Skript.jar/config.sk", false, false, ":"); + + File backup = FileUtils.backup(configFile); + boolean updated = mainConfig.updateNodes(newConfig); + mainConfig.getMainNode().set(version.key, Skript.getVersion().toString()); + mainConfig.save(configFile); + SkriptConfig.mainConfig = mainConfig; + + if (updated) { + Skript.info("Your configuration has been updated to the latest version. " + + "A backup of your old config file has been created as " + backup.getName()); + } else { + Skript.info("Your configuration is outdated, but no changes were performed. " + + "A backup of your config file has been created as " + backup.getName()); } - } catch (final IOException e) { - Skript.error("Could not load the new config from the jar file: " + e.getLocalizedMessage()); + } catch (IOException ex) { + Skript.exception(ex, "Could not update the main config"); + return; } } - - mc.load(SkriptConfig.class); - -// if (!keepConfigsLoaded.value()) -// mainConfig = null; - } catch (final RuntimeException e) { - Skript.exception(e, "An error occurred while loading the config"); - return false; + + mainConfig.load(SkriptConfig.class); + } catch (RuntimeException ex) { + Skript.exception(ex, "An error occurred while loading the config"); } // trigger reload event handlers eventRegistry().events(ReloadEvent.class).forEach(ReloadEvent::onReload); - - return true; } } diff --git a/src/main/java/ch/njol/skript/SkriptEventHandler.java b/src/main/java/ch/njol/skript/SkriptEventHandler.java index 7b9947e8486..00901afa9c2 100644 --- a/src/main/java/ch/njol/skript/SkriptEventHandler.java +++ b/src/main/java/ch/njol/skript/SkriptEventHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; import ch.njol.skript.lang.SkriptEvent; diff --git a/src/main/java/ch/njol/skript/SkriptUpdater.java b/src/main/java/ch/njol/skript/SkriptUpdater.java index 51500f52c93..97c87ba2fd3 100644 --- a/src/main/java/ch/njol/skript/SkriptUpdater.java +++ b/src/main/java/ch/njol/skript/SkriptUpdater.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/aliases/Aliases.java b/src/main/java/ch/njol/skript/aliases/Aliases.java index ad41fdb8508..de3562c787c 100644 --- a/src/main/java/ch/njol/skript/aliases/Aliases.java +++ b/src/main/java/ch/njol/skript/aliases/Aliases.java @@ -447,12 +447,7 @@ private static void loadMissingAliases() { Skript.warning("An item that has the id 'mod:item' can be used as 'mod's item' or 'item from mod'."); Skript.warning("WARNING: Skript does not officially support any modded servers."); Skript.warning("Any issues you encounter related to modded items will be your responsibility to fix."); - Skript.warning("The server will keep loading after 5 seconds."); Skript.warning("=============================================================="); - try { - Thread.sleep(5000L); - } catch (InterruptedException ignored) { - } } } diff --git a/src/main/java/ch/njol/skript/aliases/AliasesMap.java b/src/main/java/ch/njol/skript/aliases/AliasesMap.java index 143f5264060..b42424b5178 100644 --- a/src/main/java/ch/njol/skript/aliases/AliasesMap.java +++ b/src/main/java/ch/njol/skript/aliases/AliasesMap.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/aliases/AliasesParser.java b/src/main/java/ch/njol/skript/aliases/AliasesParser.java index e4a0891b689..623a86d64ca 100644 --- a/src/main/java/ch/njol/skript/aliases/AliasesParser.java +++ b/src/main/java/ch/njol/skript/aliases/AliasesParser.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/aliases/InvalidMinecraftIdException.java b/src/main/java/ch/njol/skript/aliases/InvalidMinecraftIdException.java index a4074477e75..12235757b35 100644 --- a/src/main/java/ch/njol/skript/aliases/InvalidMinecraftIdException.java +++ b/src/main/java/ch/njol/skript/aliases/InvalidMinecraftIdException.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; public class InvalidMinecraftIdException extends IllegalArgumentException { diff --git a/src/main/java/ch/njol/skript/aliases/ItemData.java b/src/main/java/ch/njol/skript/aliases/ItemData.java index f18812aabb8..a7a16ab8dc3 100644 --- a/src/main/java/ch/njol/skript/aliases/ItemData.java +++ b/src/main/java/ch/njol/skript/aliases/ItemData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/aliases/ItemFlags.java b/src/main/java/ch/njol/skript/aliases/ItemFlags.java index b39b0b93c87..d14fed568bb 100644 --- a/src/main/java/ch/njol/skript/aliases/ItemFlags.java +++ b/src/main/java/ch/njol/skript/aliases/ItemFlags.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; diff --git a/src/main/java/ch/njol/skript/aliases/ItemType.java b/src/main/java/ch/njol/skript/aliases/ItemType.java index 39ce6d21962..4cbea58df59 100644 --- a/src/main/java/ch/njol/skript/aliases/ItemType.java +++ b/src/main/java/ch/njol/skript/aliases/ItemType.java @@ -4,6 +4,8 @@ import ch.njol.skript.bukkitutil.BukkitUnsafe; import ch.njol.skript.bukkitutil.ItemUtils; import ch.njol.skript.lang.Unit; +import ch.njol.skript.lang.util.common.AnyAmount; +import ch.njol.skript.lang.util.common.AnyNamed; import ch.njol.skript.localization.Adjective; import ch.njol.skript.localization.GeneralWords; import ch.njol.skript.localization.Language; @@ -35,6 +37,7 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.NotSerializableException; @@ -55,7 +58,8 @@ import java.util.stream.Collectors; @ContainerType(ItemStack.class) -public class ItemType implements Unit, Iterable, Container, YggdrasilExtendedSerializable { +public class ItemType implements Unit, Iterable, Container, YggdrasilExtendedSerializable, + AnyNamed, AnyAmount { static { // This handles updating ItemType and ItemData variable records @@ -1444,4 +1448,37 @@ public ItemType getBaseType() { return copy; } + @Override + public @Nullable String name() { + ItemMeta meta = this.getItemMeta(); + return meta.hasDisplayName() ? meta.getDisplayName() : null; + } + + @Override + public boolean supportsNameChange() { + return true; + } + + @Override + public void setName(String name) { + ItemMeta meta = this.getItemMeta(); + meta.setDisplayName(name); + this.setItemMeta(meta); + } + + @Override + public @NotNull Number amount() { + return this.getAmount(); + } + + @Override + public boolean supportsAmountChange() { + return true; + } + + @Override + public void setAmount(@Nullable Number amount) throws UnsupportedOperationException { + this.setAmount(amount != null ? amount.intValue() : 0); + } + } diff --git a/src/main/java/ch/njol/skript/aliases/MatchQuality.java b/src/main/java/ch/njol/skript/aliases/MatchQuality.java index 58bac3dd2d5..8f863c7e0ca 100644 --- a/src/main/java/ch/njol/skript/aliases/MatchQuality.java +++ b/src/main/java/ch/njol/skript/aliases/MatchQuality.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; /** diff --git a/src/main/java/ch/njol/skript/aliases/MaterialName.java b/src/main/java/ch/njol/skript/aliases/MaterialName.java index d79912b9103..67fe60be0cb 100644 --- a/src/main/java/ch/njol/skript/aliases/MaterialName.java +++ b/src/main/java/ch/njol/skript/aliases/MaterialName.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/aliases/ScriptAliases.java b/src/main/java/ch/njol/skript/aliases/ScriptAliases.java index 6a5386f3b94..de6575e20a8 100644 --- a/src/main/java/ch/njol/skript/aliases/ScriptAliases.java +++ b/src/main/java/ch/njol/skript/aliases/ScriptAliases.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.aliases; diff --git a/src/main/java/ch/njol/skript/bukkitutil/ClickEventTracker.java b/src/main/java/ch/njol/skript/bukkitutil/ClickEventTracker.java index a0ad94999be..0a2188ae0f3 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/ClickEventTracker.java +++ b/src/main/java/ch/njol/skript/bukkitutil/ClickEventTracker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import java.util.HashMap; diff --git a/src/main/java/ch/njol/skript/bukkitutil/CommandReloader.java b/src/main/java/ch/njol/skript/bukkitutil/CommandReloader.java index e7ae58015f0..aa730e1ad0c 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/CommandReloader.java +++ b/src/main/java/ch/njol/skript/bukkitutil/CommandReloader.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import java.lang.reflect.Method; diff --git a/src/main/java/ch/njol/skript/bukkitutil/DamageUtils.java b/src/main/java/ch/njol/skript/bukkitutil/DamageUtils.java new file mode 100644 index 00000000000..02f74bef6bb --- /dev/null +++ b/src/main/java/ch/njol/skript/bukkitutil/DamageUtils.java @@ -0,0 +1,41 @@ +package ch.njol.skript.bukkitutil; + +import org.bukkit.damage.DamageSource; +import org.bukkit.damage.DamageType; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.jetbrains.annotations.NotNull; + +public class DamageUtils { + + @SuppressWarnings("UnstableApiUsage") + public static @NotNull DamageSource getDamageSourceFromCause(DamageCause cause) { + return DamageSource.builder(switch (cause) { + case KILL, SUICIDE -> DamageType.GENERIC_KILL; + case WORLD_BORDER, VOID -> DamageType.OUT_OF_WORLD; + case CONTACT -> DamageType.CACTUS; + case SUFFOCATION -> DamageType.IN_WALL; + case FALL -> DamageType.FALL; + case FIRE -> DamageType.ON_FIRE; + case FIRE_TICK -> DamageType.IN_FIRE; + case LAVA -> DamageType.LAVA; + case DROWNING -> DamageType.DROWN; + case BLOCK_EXPLOSION, ENTITY_EXPLOSION -> DamageType.EXPLOSION; + case LIGHTNING -> DamageType.LIGHTNING_BOLT; + case STARVATION -> DamageType.STARVE; + case MAGIC, POISON -> DamageType.MAGIC; + case WITHER -> DamageType.WITHER; + case FALLING_BLOCK -> DamageType.FALLING_BLOCK; + case THORNS -> DamageType.THORNS; + case DRAGON_BREATH -> DamageType.DRAGON_BREATH; + case FLY_INTO_WALL -> DamageType.FLY_INTO_WALL; + case HOT_FLOOR -> DamageType.HOT_FLOOR; + case CAMPFIRE -> DamageType.CAMPFIRE; + case CRAMMING -> DamageType.CRAMMING; + case DRYOUT -> DamageType.DRY_OUT; + case FREEZE -> DamageType.FREEZE; + case SONIC_BOOM -> DamageType.SONIC_BOOM; + default -> DamageType.GENERIC; + }).build(); + } + +} diff --git a/src/main/java/ch/njol/skript/bukkitutil/EnchantmentUtils.java b/src/main/java/ch/njol/skript/bukkitutil/EnchantmentUtils.java index 7247bba5d37..e43574d9f5e 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/EnchantmentUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/EnchantmentUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import ch.njol.skript.classes.ClassInfo; diff --git a/src/main/java/ch/njol/skript/bukkitutil/EntityUtils.java b/src/main/java/ch/njol/skript/bukkitutil/EntityUtils.java index 0da7aee9a66..2808d6637ae 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/EntityUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/EntityUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/bukkitutil/HealthUtils.java b/src/main/java/ch/njol/skript/bukkitutil/HealthUtils.java index aae3224b409..a6955604cc1 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/HealthUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/HealthUtils.java @@ -2,6 +2,8 @@ import ch.njol.skript.Skript; import ch.njol.util.Math2; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import org.bukkit.attribute.Attributable; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; @@ -13,10 +15,16 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - public class HealthUtils { + private static final @Nullable Constructor OLD_DAMAGE_EVENT_CONSTRUCTOR; + + static { + Constructor constructor = null; + try { + constructor = EntityDamageEvent.class.getConstructor(Damageable.class, DamageCause.class, double.class); + } catch (NoSuchMethodException ignored) {} + OLD_DAMAGE_EVENT_CONSTRUCTOR = constructor; + } private static final Attribute MAX_HEALTH; static { @@ -29,80 +37,95 @@ public class HealthUtils { /** * Get the health of an entity - * @param e Entity to get health from + * + * @param damageable Entity to get health from * @return The amount of hearts the entity has left */ - public static double getHealth(Damageable e) { - if (e.isDead()) + public static double getHealth(Damageable damageable) { + if (damageable.isDead()) return 0; - return e.getHealth() / 2; + return damageable.getHealth() / 2; } - + /** * Set the health of an entity - * @param e Entity to set health for + * + * @param damageable Entity to set health for * @param health The amount of hearts to set */ - public static void setHealth(Damageable e, double health) { - e.setHealth(Math2.fit(0, health, getMaxHealth(e)) * 2); + public static void setHealth(Damageable damageable, double health) { + damageable.setHealth(Math2.fit(0, health, getMaxHealth(damageable)) * 2); } - + /** * Get the max health an entity has - * @param e Entity to get max health from + * + * @param damageable Entity to get max health from * @return How many hearts the entity can have at most */ - public static double getMaxHealth(Damageable e) { - AttributeInstance attributeInstance = ((Attributable) e).getAttribute(MAX_HEALTH); + public static double getMaxHealth(Damageable damageable) { + AttributeInstance attributeInstance = ((Attributable) damageable).getAttribute(MAX_HEALTH); assert attributeInstance != null; return attributeInstance.getValue() / 2; } - + /** * Set the max health an entity can have - * @param e Entity to set max health for + * + * @param damageable Entity to set max health for * @param health How many hearts the entity can have at most */ - public static void setMaxHealth(Damageable e, double health) { - AttributeInstance attributeInstance = ((Attributable) e).getAttribute(MAX_HEALTH); + public static void setMaxHealth(Damageable damageable, double health) { + AttributeInstance attributeInstance = ((Attributable) damageable).getAttribute(MAX_HEALTH); assert attributeInstance != null; attributeInstance.setBaseValue(health * 2); } - + /** * Apply damage to an entity - * @param e Entity to apply damage to - * @param d Amount of hearts to damage + * + * @param damageable Entity to apply damage to + * @param damage Amount of hearts to damage */ - public static void damage(Damageable e, double d) { - if (d < 0) { - heal(e, -d); + public static void damage(Damageable damageable, double damage) { + if (damage < 0) { + heal(damageable, -damage); return; } - e.damage(d * 2); + damageable.damage(damage * 2); + } + + @SuppressWarnings("UnstableApiUsage") + public static void damage(Damageable damageable, double damage, DamageSource cause) { + if (damage < 0) { + heal(damageable, -damage); + return; + } + damageable.damage(damage * 2, cause); } /** * Heal an entity - * @param e Entity to heal - * @param h Amount of hearts to heal + * + * @param damageable Entity to heal + * @param health Amount of hearts to heal */ - public static void heal(Damageable e, double h) { - if (h < 0) { - damage(e, -h); + public static void heal(Damageable damageable, double health) { + if (health < 0) { + damage(damageable, -health); return; } - setHealth(e, getHealth(e) + h); + setHealth(damageable, getHealth(damageable) + health); } - - public static double getDamage(EntityDamageEvent e) { - return e.getDamage() / 2; + + public static double getDamage(EntityDamageEvent event) { + return event.getDamage() / 2; } - - public static double getFinalDamage(EntityDamageEvent e) { - return e.getFinalDamage() / 2; + + public static double getFinalDamage(EntityDamageEvent event) { + return event.getFinalDamage() / 2; } - + public static void setDamage(EntityDamageEvent event, double damage) { event.setDamage(damage * 2); // Set last damage manually as Bukkit doesn't appear to do that @@ -110,27 +133,15 @@ public static void setDamage(EntityDamageEvent event, double damage) { ((LivingEntity) event.getEntity()).setLastDamage(damage * 2); } - @Nullable - private static final Constructor OLD_DAMAGE_EVENT_CONSTRUCTOR; - - static { - Constructor constructor = null; - try { - constructor = EntityDamageEvent.class.getConstructor(Damageable.class, DamageCause.class, double.class); - } catch (NoSuchMethodException ignored) { } - OLD_DAMAGE_EVENT_CONSTRUCTOR = constructor; - } - - public static void setDamageCause(Damageable e, DamageCause cause) { + public static void setDamageCause(Damageable damageable, DamageCause cause) { if (OLD_DAMAGE_EVENT_CONSTRUCTOR != null) { try { - e.setLastDamageCause(OLD_DAMAGE_EVENT_CONSTRUCTOR.newInstance(e, cause, 0)); + damageable.setLastDamageCause(OLD_DAMAGE_EVENT_CONSTRUCTOR.newInstance(damageable, cause, 0)); } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) { Skript.exception("Failed to set last damage cause"); } } else { - e.setLastDamageCause(new EntityDamageEvent(e, cause, DamageSource.builder(DamageType.GENERIC).build(), 0)); + damageable.setLastDamageCause(new EntityDamageEvent(damageable, cause, DamageSource.builder(DamageType.GENERIC).build(), 0)); } } - } diff --git a/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java b/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java index 2af432ce6d3..ae37c272750 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/bukkitutil/PaperEntityUtils.java b/src/main/java/ch/njol/skript/bukkitutil/PaperEntityUtils.java index 00a95c7ffca..b488fcbc9a7 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/PaperEntityUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/PaperEntityUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import java.util.EnumSet; diff --git a/src/main/java/ch/njol/skript/bukkitutil/PassengerUtils.java b/src/main/java/ch/njol/skript/bukkitutil/PassengerUtils.java index 70b84941f93..9d2af9fbfb0 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/PassengerUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/PassengerUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import java.lang.reflect.Method; diff --git a/src/main/java/ch/njol/skript/bukkitutil/PlayerUtils.java b/src/main/java/ch/njol/skript/bukkitutil/PlayerUtils.java index 5132dc521c6..6f3791fa34d 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/PlayerUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/PlayerUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/bukkitutil/SoundUtils.java b/src/main/java/ch/njol/skript/bukkitutil/SoundUtils.java index 36ad5136d9a..0debb60adf4 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/SoundUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/SoundUtils.java @@ -2,6 +2,7 @@ import org.bukkit.Keyed; import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.Sound; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,19 +26,17 @@ public final class SoundUtils { soundString = soundString.toUpperCase(Locale.ENGLISH); if (SOUND_IS_INTERFACE) { try { - //noinspection deprecation + //noinspection deprecation,removal return Sound.valueOf(soundString).getKey(); - } catch (IllegalArgumentException ignore) { - } + } catch (Exception ignored) {} } else { try { //noinspection unchecked,rawtypes Enum soundEnum = Enum.valueOf((Class) Sound.class, soundString); return ((Keyed) soundEnum).getKey(); - } catch (IllegalArgumentException ignore) { - } + } catch (IllegalArgumentException ignored) {} } - return null; + return NamespacedKey.fromString(soundString.toLowerCase(Locale.ENGLISH)); } /** @@ -47,11 +46,23 @@ public final class SoundUtils { */ public static @NotNull NamespacedKey getKey(Sound sound) { if (SOUND_IS_INTERFACE) { - //noinspection deprecation + //noinspection deprecation,removal return sound.getKey(); } else { return ((Keyed) sound).getKey(); } } + /** + * Retrieves the sound correlating to the provided {@code soundString} + * @param soundString The string to get the correlating sound + * @return The correlating {@link Sound} + */ + public static @Nullable Sound getSound(String soundString) { + NamespacedKey key = getKey(soundString); + if (key == null) + return null; + return Registry.SOUNDS.get(key); + } + } diff --git a/src/main/java/ch/njol/skript/bukkitutil/WorldUtils.java b/src/main/java/ch/njol/skript/bukkitutil/WorldUtils.java index b08e464088b..9862eb379c4 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/WorldUtils.java +++ b/src/main/java/ch/njol/skript/bukkitutil/WorldUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/bukkitutil/block/BlockCompat.java b/src/main/java/ch/njol/skript/bukkitutil/block/BlockCompat.java index f6866b595f7..cd1045b47ec 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/block/BlockCompat.java +++ b/src/main/java/ch/njol/skript/bukkitutil/block/BlockCompat.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil.block; import java.util.Map; diff --git a/src/main/java/ch/njol/skript/bukkitutil/block/BlockSetter.java b/src/main/java/ch/njol/skript/bukkitutil/block/BlockSetter.java index e428734fe20..bfcdb41854a 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/block/BlockSetter.java +++ b/src/main/java/ch/njol/skript/bukkitutil/block/BlockSetter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil.block; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/bukkitutil/block/BlockValues.java b/src/main/java/ch/njol/skript/bukkitutil/block/BlockValues.java index 0cf4e1a3c21..48a338d2174 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/block/BlockValues.java +++ b/src/main/java/ch/njol/skript/bukkitutil/block/BlockValues.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil.block; import ch.njol.skript.aliases.MatchQuality; diff --git a/src/main/java/ch/njol/skript/bukkitutil/block/NewBlockCompat.java b/src/main/java/ch/njol/skript/bukkitutil/block/NewBlockCompat.java index c20febc95e9..6307a4634cd 100644 --- a/src/main/java/ch/njol/skript/bukkitutil/block/NewBlockCompat.java +++ b/src/main/java/ch/njol/skript/bukkitutil/block/NewBlockCompat.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.bukkitutil.block; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/classes/AnyInfo.java b/src/main/java/ch/njol/skript/classes/AnyInfo.java new file mode 100644 index 00000000000..283e0c5189b --- /dev/null +++ b/src/main/java/ch/njol/skript/classes/AnyInfo.java @@ -0,0 +1,40 @@ +package ch.njol.skript.classes; + +import ch.njol.skript.lang.util.common.AnyProvider; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +/** + * A special kind of {@link ClassInfo} for dealing with 'any'-accepting types. + * These auto-generate their user patterns (e.g. {@code named} -> {@code any named thing}). + * + * @see AnyProvider + */ +public class AnyInfo extends ClassInfo { + + /** + * @param c The class + * @param codeName The name used in patterns + */ + public AnyInfo(Class c, String codeName) { + super(c, codeName); + this.user("(any )?" + codeName + " (thing|object)s?"); + } + + @Override + public ClassInfo user(String... userInputPatterns) throws PatternSyntaxException { + if (this.userInputPatterns == null) + return super.user(userInputPatterns); + // Allow appending the patterns. + List list = new ArrayList<>(List.of(this.userInputPatterns)); + for (String pattern : userInputPatterns) { + list.add(Pattern.compile(pattern)); + } + this.userInputPatterns = list.toArray(new Pattern[0]); + return this; + } + +} diff --git a/src/main/java/ch/njol/skript/classes/Arithmetic.java b/src/main/java/ch/njol/skript/classes/Arithmetic.java index 2365c3a64da..f381e012d52 100644 --- a/src/main/java/ch/njol/skript/classes/Arithmetic.java +++ b/src/main/java/ch/njol/skript/classes/Arithmetic.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; /** diff --git a/src/main/java/ch/njol/skript/classes/ChainedConverter.java b/src/main/java/ch/njol/skript/classes/ChainedConverter.java index 7e560d3dd20..418d8620d31 100644 --- a/src/main/java/ch/njol/skript/classes/ChainedConverter.java +++ b/src/main/java/ch/njol/skript/classes/ChainedConverter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/classes/Changer.java b/src/main/java/ch/njol/skript/classes/Changer.java index 138f6279740..544433b6ee6 100644 --- a/src/main/java/ch/njol/skript/classes/Changer.java +++ b/src/main/java/ch/njol/skript/classes/Changer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/classes/ClassInfo.java b/src/main/java/ch/njol/skript/classes/ClassInfo.java index 56b24d4dceb..3c96028c58a 100644 --- a/src/main/java/ch/njol/skript/classes/ClassInfo.java +++ b/src/main/java/ch/njol/skript/classes/ClassInfo.java @@ -28,23 +28,22 @@ */ @SuppressFBWarnings("DM_STRING_VOID_CTOR") public class ClassInfo implements Debuggable { - + private final Class c; private final String codeName; private final Noun name; - + @Nullable private DefaultExpression defaultExpression = null; - + @Nullable private Parser parser = null; - + @Nullable private Cloner cloner = null; - - @Nullable - private Pattern[] userInputPatterns = null; - + + @Nullable Pattern[] userInputPatterns = null; + @Nullable private Changer changer = null; @@ -55,12 +54,12 @@ public class ClassInfo implements Debuggable { private Serializer serializer = null; @Nullable private Class serializeAs = null; - + @Nullable private Arithmetic math = null; @Nullable private Class mathRelativeType = null; - + @Nullable private String docName = null; @Nullable @@ -73,13 +72,13 @@ public class ClassInfo implements Debuggable { private String since = null; @Nullable private String[] requiredPlugins = null; - + /** * Overrides documentation id assigned from class name. */ @Nullable private String documentationId = null; - + /** * @param c The class * @param codeName The name used in patterns @@ -91,7 +90,7 @@ public ClassInfo(final Class c, final String codeName) { this.codeName = codeName; name = new Noun("types." + codeName); } - + /** * Incorrect spelling in method name. This will be removed in the future. */ @@ -99,13 +98,13 @@ public ClassInfo(final Class c, final String codeName) { public static boolean isVaildCodeName(final String name) { return isValidCodeName(name); } - + public static boolean isValidCodeName(final String name) { - return name.matches("[a-z0-9]+"); + return name.matches("(?:any-)?[a-z0-9]+"); } - + // === FACTORY METHODS === - + /** * @param parser A parser to parse values of this class or null if not applicable */ @@ -114,7 +113,7 @@ public ClassInfo parser(final Parser parser) { this.parser = parser; return this; } - + /** * @param cloner A {@link Cloner} to clone values when setting variables * or passing function arguments. @@ -124,7 +123,7 @@ public ClassInfo cloner(Cloner cloner) { this.cloner = cloner; return this; } - + /** * @param userInputPatterns Regex patterns to match this class, e.g. in the expressions loop-[type], random [type] out of ..., or as command arguments. These patterns * must be english and match singular and plural. @@ -139,7 +138,7 @@ public ClassInfo user(final String... userInputPatterns) throws PatternSyntax } return this; } - + /** * @param defaultExpression The default (event) value of this class or null if not applicable * @see EventValueExpression @@ -187,7 +186,7 @@ public ClassInfo serializer(final Serializer serializer) { serializer.register(this); return this; } - + public ClassInfo serializeAs(final Class serializeAs) { assert this.serializeAs == null; if (serializer != null) @@ -195,12 +194,12 @@ public ClassInfo serializeAs(final Class serializeAs) { this.serializeAs = serializeAs; return this; } - + @Deprecated public ClassInfo changer(final SerializableChanger changer) { return changer((Changer) changer); } - + public ClassInfo changer(final Changer changer) { assert this.changer == null; this.changer = changer; @@ -221,15 +220,15 @@ public ClassInfo math(final Class relativeType, final Arithmetic name(final String name) { this.docName = name; return this; } - + /** * Only used for Skript's documentation. - * + * * @param description * @return This ClassInfo object */ @@ -250,10 +249,10 @@ public ClassInfo description(final String... description) { this.description = description; return this; } - + /** * Only used for Skript's documentation. - * + * * @param usage * @return This ClassInfo object */ @@ -262,10 +261,10 @@ public ClassInfo usage(final String... usage) { this.usage = usage; return this; } - + /** * Only used for Skript's documentation. - * + * * @param examples * @return This ClassInfo object */ @@ -274,10 +273,10 @@ public ClassInfo examples(final String... examples) { this.examples = examples; return this; } - + /** * Only used for Skript's documentation. - * + * * @param since * @return This ClassInfo object */ @@ -286,7 +285,7 @@ public ClassInfo since(final String since) { this.since = since; return this; } - + /** * Other plugin dependencies for this ClassInfo. * @@ -300,7 +299,7 @@ public ClassInfo requiredPlugins(final String... pluginNames) { this.requiredPlugins = pluginNames; return this; } - + /** * Overrides default documentation id, which is assigned from class name. * This is especially useful for inner classes whose names are useless without @@ -313,36 +312,36 @@ public ClassInfo documentationId(String id) { this.documentationId = id; return this; } - + // === GETTERS === - + public Class getC() { return c; } - + public Noun getName() { return name; } - + public String getCodeName() { return codeName; } - + @Nullable public DefaultExpression getDefaultExpression() { return defaultExpression; } - + @Nullable public Parser getParser() { return parser; } - + @Nullable public Cloner getCloner() { return cloner; } - + /** * Clones the given object using {@link ClassInfo#cloner}, * returning the given object if no {@link Cloner} is registered. @@ -350,12 +349,12 @@ public Cloner getCloner() { public T clone(T t) { return cloner == null ? t : cloner.clone(t); } - + @Nullable public Pattern[] getUserInputPatterns() { return userInputPatterns; } - + @Nullable public Changer getChanger() { return changer; @@ -372,12 +371,12 @@ public Supplier> getSupplier() { public Serializer getSerializer() { return serializer; } - + @Nullable public Class getSerializeAs() { return serializeAs; } - + @Nullable @Deprecated public Arithmetic getMath() { @@ -389,33 +388,33 @@ public Class getSerializeAs() { public Arithmetic getRelativeMath() { return (Arithmetic) math; } - + @Nullable @Deprecated public Class getMathRelativeType() { return mathRelativeType; } - + @Nullable public String[] getDescription() { return description; } - + @Nullable public String[] getUsage() { return usage; } - + @Nullable public String[] getExamples() { return examples; } - + @Nullable public String getSince() { return since; } - + @Nullable public String getDocName() { return docName; @@ -425,7 +424,7 @@ public String getDocName() { public String[] getRequiredPlugins() { return requiredPlugins; } - + /** * Gets overridden documentation id of this this type. If no override has * been set, null is returned and the caller may try to derive this from @@ -440,13 +439,13 @@ public String getDocumentationID() { public boolean hasDocs() { return getDocName() != null && !ClassInfo.NO_DOC.equals(getDocName()); } - + // === ORDERING === - + @Nullable private Set before; private final Set after = new HashSet<>(); - + /** * Sets one or more classes that this class should occur before in the class info list. This only affects the order in which classes are parsed if it's unknown of which type * the parsed string is. @@ -454,7 +453,7 @@ public boolean hasDocs() { * Please note that subclasses will always be registered before superclasses, no matter what is defined here or in {@link #after(String...)}. *

* This list can safely contain classes that may not exist. - * + * * @param before * @return this ClassInfo */ @@ -463,7 +462,7 @@ public ClassInfo before(final String... before) { this.before = new HashSet<>(Arrays.asList(before)); return this; } - + /** * Sets one or more classes that this class should occur after in the class info list. This only affects the order in which classes are parsed if it's unknown of which type * the parsed string is. @@ -471,7 +470,7 @@ public ClassInfo before(final String... before) { * Please note that subclasses will always be registered before superclasses, no matter what is defined here or in {@link #before(String...)}. *

* This list can safely contain classes that may not exist. - * + * * @param after * @return this ClassInfo */ @@ -479,7 +478,7 @@ public ClassInfo after(final String... after) { this.after.addAll(Arrays.asList(after)); return this; } - + /** * @return Set of classes that should be after this one. May return null. */ @@ -487,26 +486,26 @@ public ClassInfo after(final String... after) { public Set before() { return before; } - + /** * @return Set of classes that should be before this one. Never returns null. */ public Set after() { return after; } - + // === GENERAL === - + @Override @NotNull public String toString() { return getName().getSingular(); } - + public String toString(final int flags) { return getName().toString(flags); } - + @Override @NotNull public String toString(final @Nullable Event event, final boolean debug) { @@ -514,5 +513,5 @@ public String toString(final @Nullable Event event, final boolean debug) { return codeName + " (" + c.getCanonicalName() + ")"; return getName().getSingular(); } - + } diff --git a/src/main/java/ch/njol/skript/classes/Cloner.java b/src/main/java/ch/njol/skript/classes/Cloner.java index 4625980496a..6f1e35d2d22 100644 --- a/src/main/java/ch/njol/skript/classes/Cloner.java +++ b/src/main/java/ch/njol/skript/classes/Cloner.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; /** diff --git a/src/main/java/ch/njol/skript/classes/Comparator.java b/src/main/java/ch/njol/skript/classes/Comparator.java index ae71dd3c8de..31e8ac607e0 100644 --- a/src/main/java/ch/njol/skript/classes/Comparator.java +++ b/src/main/java/ch/njol/skript/classes/Comparator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; /** diff --git a/src/main/java/ch/njol/skript/classes/ConfigurationSerializer.java b/src/main/java/ch/njol/skript/classes/ConfigurationSerializer.java index b70d843ba7a..de0491c1b62 100644 --- a/src/main/java/ch/njol/skript/classes/ConfigurationSerializer.java +++ b/src/main/java/ch/njol/skript/classes/ConfigurationSerializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import java.io.NotSerializableException; diff --git a/src/main/java/ch/njol/skript/classes/Converter.java b/src/main/java/ch/njol/skript/classes/Converter.java index abb6399dacb..f9aefe2d8f2 100644 --- a/src/main/java/ch/njol/skript/classes/Converter.java +++ b/src/main/java/ch/njol/skript/classes/Converter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import ch.njol.skript.lang.Debuggable; diff --git a/src/main/java/ch/njol/skript/classes/EnumSerializer.java b/src/main/java/ch/njol/skript/classes/EnumSerializer.java index 812ec4491b4..a4440e5e192 100644 --- a/src/main/java/ch/njol/skript/classes/EnumSerializer.java +++ b/src/main/java/ch/njol/skript/classes/EnumSerializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import java.io.StreamCorruptedException; diff --git a/src/main/java/ch/njol/skript/classes/InverseComparator.java b/src/main/java/ch/njol/skript/classes/InverseComparator.java index dc9ccf5f003..a8ae1d2dba8 100644 --- a/src/main/java/ch/njol/skript/classes/InverseComparator.java +++ b/src/main/java/ch/njol/skript/classes/InverseComparator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; /** diff --git a/src/main/java/ch/njol/skript/classes/NumberArithmetic.java b/src/main/java/ch/njol/skript/classes/NumberArithmetic.java index 71c035ebd7d..cc5e487f7a1 100644 --- a/src/main/java/ch/njol/skript/classes/NumberArithmetic.java +++ b/src/main/java/ch/njol/skript/classes/NumberArithmetic.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; /** diff --git a/src/main/java/ch/njol/skript/classes/Parser.java b/src/main/java/ch/njol/skript/classes/Parser.java index 9060a36b430..16f85792571 100644 --- a/src/main/java/ch/njol/skript/classes/Parser.java +++ b/src/main/java/ch/njol/skript/classes/Parser.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/classes/SerializableChanger.java b/src/main/java/ch/njol/skript/classes/SerializableChanger.java index 2bbbc86e44b..e2967a6de81 100644 --- a/src/main/java/ch/njol/skript/classes/SerializableChanger.java +++ b/src/main/java/ch/njol/skript/classes/SerializableChanger.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; /** diff --git a/src/main/java/ch/njol/skript/classes/SerializableChecker.java b/src/main/java/ch/njol/skript/classes/SerializableChecker.java index 3b7d4e3643f..216e2b750b1 100644 --- a/src/main/java/ch/njol/skript/classes/SerializableChecker.java +++ b/src/main/java/ch/njol/skript/classes/SerializableChecker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import ch.njol.util.Checker; diff --git a/src/main/java/ch/njol/skript/classes/SerializableGetter.java b/src/main/java/ch/njol/skript/classes/SerializableGetter.java index 0dbd5c2098b..69b37ceeb65 100644 --- a/src/main/java/ch/njol/skript/classes/SerializableGetter.java +++ b/src/main/java/ch/njol/skript/classes/SerializableGetter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import ch.njol.skript.util.Getter; diff --git a/src/main/java/ch/njol/skript/classes/Serializer.java b/src/main/java/ch/njol/skript/classes/Serializer.java index 64b9375e27a..aec12090692 100644 --- a/src/main/java/ch/njol/skript/classes/Serializer.java +++ b/src/main/java/ch/njol/skript/classes/Serializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import java.io.NotSerializableException; diff --git a/src/main/java/ch/njol/skript/classes/VectorArithmethic.java b/src/main/java/ch/njol/skript/classes/VectorArithmethic.java index 5bdac60af9a..a4d7db28b4e 100644 --- a/src/main/java/ch/njol/skript/classes/VectorArithmethic.java +++ b/src/main/java/ch/njol/skript/classes/VectorArithmethic.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import org.bukkit.util.Vector; diff --git a/src/main/java/ch/njol/skript/classes/YggdrasilSerializer.java b/src/main/java/ch/njol/skript/classes/YggdrasilSerializer.java index 5fab3d52342..5add92542c0 100644 --- a/src/main/java/ch/njol/skript/classes/YggdrasilSerializer.java +++ b/src/main/java/ch/njol/skript/classes/YggdrasilSerializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes; import java.io.NotSerializableException; diff --git a/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java b/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java index 64a47196bb5..6acf2d9be75 100644 --- a/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java +++ b/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.data; import ch.njol.skript.Skript; @@ -67,14 +49,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentOffer; -import org.bukkit.entity.Cat; -import org.bukkit.entity.Wolf; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.*; import org.bukkit.entity.Panda.Gene; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityPotionEffectEvent; @@ -1565,6 +1541,33 @@ public String toVariableNameString(EnchantmentOffer eo) { .name("Experience Cooldown Change Reason") .description("Represents a change reason of an experience cooldown change event.") .since("INSERT VERSION")); + + Classes.registerClass(new RegistryClassInfo<>(Villager.Type.class, Registry.VILLAGER_TYPE, "villagertype", "villager types") + .user("villager ?types?") + .name("Villager Type") + .description("Represents the different types of villagers. These are usually the biomes a villager can be from.") + .after("biome") + .since("INSERT VERSION")); + + Classes.registerClass(new RegistryClassInfo<>(Villager.Profession.class, Registry.VILLAGER_PROFESSION, "villagerprofession", "villager professions") + .user("villager ?professions?") + .name("Villager Profession") + .description("Represents the different professions of villagers.") + .since("INSERT VERSION")); + + if (Skript.classExists("org.bukkit.entity.EntitySnapshot")) { + Classes.registerClass(new ClassInfo<>(EntitySnapshot.class, "entitysnapshot") + .user("entity ?snapshots?") + .name("Entity Snapshot") + .description("Represents a snapshot of an entity's data.", + "This includes all of the data associated with an entity (its name, health, attributes, etc.), at the time this expression is used. " + + "Essentially, these are a way to create templates for entities.", + "Individual attributes of a snapshot cannot be modified or retrieved.") + .requiredPlugins("Minecraft 1.20.2+") + .since("INSERT VERSION") + ); + } + } } diff --git a/src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java b/src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java index f9a2accca7d..ab91438aaf2 100644 --- a/src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java +++ b/src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java @@ -1,18 +1,10 @@ package ch.njol.skript.classes.data; -import java.time.Duration; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalUnit; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Function; - import ch.njol.skript.Skript; import ch.njol.skript.aliases.ItemType; import ch.njol.skript.bukkitutil.InventoryUtils; import ch.njol.skript.command.CommandEvent; +import ch.njol.skript.command.ScriptCommandEvent; import ch.njol.skript.events.bukkit.ScriptEvent; import ch.njol.skript.events.bukkit.SkriptStartEvent; import ch.njol.skript.events.bukkit.SkriptStopEvent; @@ -26,18 +18,15 @@ import com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent; import com.destroystokyo.paper.event.entity.ProjectileCollideEvent; import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; +import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; import io.papermc.paper.event.entity.EntityMoveEvent; -import io.papermc.paper.event.player.PlayerInventorySlotChangeEvent; -import io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent; -import io.papermc.paper.event.player.PlayerStopUsingItemEvent; -import io.papermc.paper.event.player.PlayerTradeEvent; -import org.bukkit.*; import io.papermc.paper.event.player.*; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; +import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.entity.*; import org.bukkit.event.block.*; @@ -66,9 +55,13 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + public final class BukkitEventValues { public BukkitEventValues() { @@ -974,6 +967,8 @@ public World get(final CommandEvent e) { return e.getSender() instanceof Player ? ((Player) e.getSender()).getWorld() : null; } }, 0); + EventValues.registerEventValue(CommandEvent.class, Block.class, + event -> event.getSender() instanceof BlockCommandSender sender ? sender.getBlock() : null); // === ServerEvents === // Script load/unload event @@ -1629,24 +1624,6 @@ public ItemType get(PlayerStopUsingItemEvent event) { }, EventValues.TIME_NOW); } - // LootGenerateEvent - if (Skript.classExists("org.bukkit.event.world.LootGenerateEvent")) { - EventValues.registerEventValue(LootGenerateEvent.class, Entity.class, new Getter() { - @Override - @Nullable - public Entity get(LootGenerateEvent event) { - return event.getEntity(); - } - }, EventValues.TIME_NOW); - EventValues.registerEventValue(LootGenerateEvent.class, Location.class, new Getter() { - @Override - @Nullable - public Location get(LootGenerateEvent event) { - return event.getLootContext().getLocation(); - } - }, EventValues.TIME_NOW); - } - // EntityResurrectEvent EventValues.registerEventValue(EntityResurrectEvent.class, Slot.class, new Getter() { @Override @@ -1810,6 +1787,12 @@ public RegainReason get(EntityRegainHealthEvent event) { } }, EventValues.TIME_NOW); + // FurnaceExtractEvent + EventValues.registerEventValue(FurnaceExtractEvent.class, Player.class, FurnaceExtractEvent::getPlayer); + EventValues.registerEventValue(FurnaceExtractEvent.class, ItemStack[].class, + event -> new ItemStack[]{ItemStack.of(event.getItemType(), event.getItemAmount()) + }); + // BlockDropItemEvent EventValues.registerEventValue(BlockDropItemEvent.class, Block.class, new Getter() { @Override @@ -1894,6 +1877,13 @@ public Block get(PlayerChangeBeaconEffectEvent event) { } }, EventValues.TIME_NOW); } + + // PlayerElytraBoostEvent + if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) { + EventValues.registerEventValue(PlayerElytraBoostEvent.class, ItemStack.class, PlayerElytraBoostEvent::getItemStack); + EventValues.registerEventValue(PlayerElytraBoostEvent.class, Entity.class, PlayerElytraBoostEvent::getFirework); + } + } } diff --git a/src/main/java/ch/njol/skript/classes/data/DefaultChangers.java b/src/main/java/ch/njol/skript/classes/data/DefaultChangers.java index 7d6aff7f333..8a8ce77dc55 100644 --- a/src/main/java/ch/njol/skript/classes/data/DefaultChangers.java +++ b/src/main/java/ch/njol/skript/classes/data/DefaultChangers.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.data; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/classes/data/DefaultComparators.java b/src/main/java/ch/njol/skript/classes/data/DefaultComparators.java index dbaf030c374..f6a2759c201 100644 --- a/src/main/java/ch/njol/skript/classes/data/DefaultComparators.java +++ b/src/main/java/ch/njol/skript/classes/data/DefaultComparators.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.data; import ch.njol.skript.Skript; @@ -52,11 +34,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.EnchantmentOffer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Item; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Wither; +import org.bukkit.entity.*; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -670,6 +648,23 @@ public boolean supportsOrdering() { Comparators.registerComparator(Color.class, Color.class, (one, two) -> Relation.get(one.asBukkitColor().equals(two.asBukkitColor()))); Comparators.registerComparator(Color.class, org.bukkit.Color.class, (one, two) -> Relation.get(one.asBukkitColor().equals(two))); Comparators.registerComparator(org.bukkit.Color.class, org.bukkit.Color.class, (one, two) -> Relation.get(one.equals(two))); + + if (Skript.classExists("org.bukkit.entity.EntitySnapshot")) { + boolean SNAPSHOT_AS_STRING_EXISTS = Skript.methodExists(EntitySnapshot.class, "getAsString"); + Comparators.registerComparator(EntitySnapshot.class, EntitySnapshot.class, new Comparator() { + @Override + public Relation compare(EntitySnapshot snap1, EntitySnapshot snap2) { + if (!snap1.getEntityType().equals(snap1.getEntityType())) + return Relation.NOT_EQUAL; + boolean isEqual; + if (!SNAPSHOT_AS_STRING_EXISTS) + isEqual = snap1.equals(snap2) || snap1.hashCode() == snap2.hashCode(); + else + isEqual = snap1.getAsString().equalsIgnoreCase(snap2.getAsString()); + return Relation.get(isEqual); + } + }); + } } } diff --git a/src/main/java/ch/njol/skript/classes/data/DefaultConverters.java b/src/main/java/ch/njol/skript/classes/data/DefaultConverters.java index a90de6957d3..a73fece5a1f 100644 --- a/src/main/java/ch/njol/skript/classes/data/DefaultConverters.java +++ b/src/main/java/ch/njol/skript/classes/data/DefaultConverters.java @@ -1,39 +1,20 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.data; +import ch.njol.skript.Skript; import ch.njol.skript.aliases.ItemType; import ch.njol.skript.command.Commands; import ch.njol.skript.entity.EntityData; import ch.njol.skript.entity.EntityType; import ch.njol.skript.entity.XpOrbData; +import ch.njol.skript.lang.util.common.AnyAmount; +import ch.njol.skript.lang.util.common.AnyNamed; import ch.njol.skript.util.BlockInventoryHolder; import ch.njol.skript.util.BlockUtils; import ch.njol.skript.util.Direction; import ch.njol.skript.util.EnchantmentType; import ch.njol.skript.util.Experience; import ch.njol.skript.util.slot.Slot; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.DoubleChest; @@ -48,14 +29,19 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.plugin.Plugin; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Team; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.UnknownNullability; import org.skriptlang.skript.lang.converter.Converter; import org.skriptlang.skript.lang.converter.Converters; public class DefaultConverters { - + public DefaultConverters() {} - + static { // Number to subtypes converters Converters.registerConverter(Number.class, Byte.class, Number::byteValue); @@ -100,27 +86,27 @@ public DefaultConverters() {} return (LivingEntity) e; return null; }); - + // Block - Inventory Converters.registerConverter(Block.class, Inventory.class, b -> { if (b.getState() instanceof InventoryHolder) return ((InventoryHolder) b.getState()).getInventory(); return null; }, Commands.CONVERTER_NO_COMMAND_ARGUMENTS); - + // Entity - Inventory Converters.registerConverter(Entity.class, Inventory.class, e -> { if (e instanceof InventoryHolder) return ((InventoryHolder) e).getInventory(); return null; }, Commands.CONVERTER_NO_COMMAND_ARGUMENTS); - + // Block - ItemType Converters.registerConverter(Block.class, ItemType.class, ItemType::new, Converter.NO_LEFT_CHAINING | Commands.CONVERTER_NO_COMMAND_ARGUMENTS); // Block - Location Converters.registerConverter(Block.class, Location.class, BlockUtils::getLocation, Commands.CONVERTER_NO_COMMAND_ARGUMENTS); - + // Entity - Location Converters.registerConverter(Entity.class, Location.class, Entity::getLocation, Commands.CONVERTER_NO_COMMAND_ARGUMENTS); @@ -129,21 +115,21 @@ public DefaultConverters() {} // EntityData - EntityType Converters.registerConverter(EntityData.class, EntityType.class, data -> new EntityType(data, -1)); - + // ItemType - ItemStack Converters.registerConverter(ItemType.class, ItemStack.class, ItemType::getRandom); Converters.registerConverter(ItemStack.class, ItemType.class, ItemType::new); - + // Experience - XpOrbData Converters.registerConverter(Experience.class, XpOrbData.class, e -> new XpOrbData(e.getXP())); Converters.registerConverter(XpOrbData.class, Experience.class, e -> new Experience(e.getExperience())); - + // Slot - ItemType Converters.registerConverter(Slot.class, ItemType.class, s -> { ItemStack i = s.getItem(); return new ItemType(i != null ? i : new ItemStack(Material.AIR, 1)); }); - + // Block - InventoryHolder Converters.registerConverter(Block.class, InventoryHolder.class, b -> { BlockState s = b.getState(); @@ -162,25 +148,108 @@ public DefaultConverters() {} // InventoryHolder - Entity Converters.registerConverter(InventoryHolder.class, Entity.class, holder -> { - if (holder instanceof Entity) - return (Entity) holder; + if (holder instanceof Entity entity) + return entity; return null; }, Converter.NO_CHAINING); + // Anything with a name -> AnyNamed + Converters.registerConverter(OfflinePlayer.class, AnyNamed.class, player -> player::getName, Converter.NO_RIGHT_CHAINING); + if (Skript.classExists("org.bukkit.generator.WorldInfo")) + Converters.registerConverter(World.class, AnyNamed.class, world -> world::getName, Converter.NO_RIGHT_CHAINING); + else //noinspection RedundantCast getName method is on World itself in older versions + Converters.registerConverter(World.class, AnyNamed.class, world -> () -> ((World) world).getName(), Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(GameRule.class, AnyNamed.class, rule -> rule::getName, Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(Server.class, AnyNamed.class, server -> server::getName, Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(Plugin.class, AnyNamed.class, plugin -> plugin::getName, Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(WorldType.class, AnyNamed.class, type -> type::getName, Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(Team.class, AnyNamed.class, team -> team::getName, Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(Objective.class, AnyNamed.class, objective -> objective::getName, Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(Nameable.class, AnyNamed.class, // + nameable -> new AnyNamed() { + @Override + public @UnknownNullability String name() { + //noinspection deprecation + return nameable.getCustomName(); + } + + @Override + public boolean supportsNameChange() { + return true; + } + + @Override + public void setName(String name) { + //noinspection deprecation + nameable.setCustomName(name); + } + }, + // + Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(Block.class, AnyNamed.class, // + block -> new AnyNamed() { + @Override + public @UnknownNullability String name() { + BlockState state = block.getState(); + if (state instanceof Nameable nameable) + //noinspection deprecation + return nameable.getCustomName(); + return null; + } + + @Override + public boolean supportsNameChange() { + return true; + } + + @Override + public void setName(String name) { + BlockState state = block.getState(); + if (state instanceof Nameable nameable) + //noinspection deprecation + nameable.setCustomName(name); + } + }, + // + Converter.NO_RIGHT_CHAINING); + Converters.registerConverter(CommandSender.class, AnyNamed.class, thing -> thing::getName, Converter.NO_RIGHT_CHAINING); + // Command senders should be done last because there might be a better alternative above + + // Anything with an amount -> AnyAmount + Converters.registerConverter(ItemStack.class, AnyAmount.class, // + item -> new AnyAmount() { + + @Override + public @NotNull Number amount() { + return item.getAmount(); + } + + @Override + public boolean supportsAmountChange() { + return true; + } + + @Override + public void setAmount(Number amount) { + item.setAmount(amount != null ? amount.intValue() : 0); + } + }, + // + Converter.NO_RIGHT_CHAINING); + // InventoryHolder - Location // since the individual ones can't be trusted to chain. Converters.registerConverter(InventoryHolder.class, Location.class, holder -> { - if (holder instanceof Entity) - return ((Entity) holder).getLocation(); - if (holder instanceof Block) - return ((Block) holder).getLocation(); - if (holder instanceof BlockState) - return BlockUtils.getLocation(((BlockState) holder).getBlock()); - if (holder instanceof DoubleChest) { - DoubleChest doubleChest = (DoubleChest) holder; + if (holder instanceof Entity entity) + return entity.getLocation(); + if (holder instanceof Block block) + return block.getLocation(); + if (holder instanceof BlockState state) + return BlockUtils.getLocation(state.getBlock()); + if (holder instanceof DoubleChest doubleChest) { if (doubleChest.getLeftSide() != null) { return BlockUtils.getLocation(((BlockState) doubleChest.getLeftSide()).getBlock()); - } else if (((DoubleChest) holder).getRightSide() != null) { + } else if (doubleChest.getRightSide() != null) { return BlockUtils.getLocation(((BlockState) doubleChest.getRightSide()).getBlock()); } } diff --git a/src/main/java/ch/njol/skript/classes/data/DefaultFunctions.java b/src/main/java/ch/njol/skript/classes/data/DefaultFunctions.java index 5c770ca0d5e..3450a1a1438 100644 --- a/src/main/java/ch/njol/skript/classes/data/DefaultFunctions.java +++ b/src/main/java/ch/njol/skript/classes/data/DefaultFunctions.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.data; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java b/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java index 48bf82939fd..907de84ef89 100644 --- a/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java +++ b/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.data; import ch.njol.skript.util.Date; diff --git a/src/main/java/ch/njol/skript/classes/data/SkriptClasses.java b/src/main/java/ch/njol/skript/classes/data/SkriptClasses.java index 57704e760ee..f3e02109153 100644 --- a/src/main/java/ch/njol/skript/classes/data/SkriptClasses.java +++ b/src/main/java/ch/njol/skript/classes/data/SkriptClasses.java @@ -1,17 +1,20 @@ package ch.njol.skript.classes.data; +import ch.njol.skript.classes.*; +import ch.njol.skript.lang.util.common.AnyAmount; +import ch.njol.skript.lang.util.common.AnyContains; +import ch.njol.skript.lang.util.common.AnyNamed; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Nullable; + import ch.njol.skript.Skript; import ch.njol.skript.aliases.Aliases; import ch.njol.skript.aliases.ItemData; import ch.njol.skript.aliases.ItemType; import ch.njol.skript.bukkitutil.EnchantmentUtils; import ch.njol.skript.bukkitutil.ItemUtils; -import ch.njol.skript.classes.Changer; -import ch.njol.skript.classes.ClassInfo; -import ch.njol.skript.classes.EnumSerializer; -import ch.njol.skript.classes.Parser; -import ch.njol.skript.classes.Serializer; -import ch.njol.skript.classes.YggdrasilSerializer; import ch.njol.skript.expressions.base.EventValueExpression; import ch.njol.skript.lang.ParseContext; import ch.njol.skript.lang.util.SimpleLiteral; @@ -36,21 +39,17 @@ import ch.njol.skript.util.visual.VisualEffect; import ch.njol.skript.util.visual.VisualEffects; import ch.njol.yggdrasil.Fields; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.Nullable; import java.io.StreamCorruptedException; -import java.util.Arrays; import java.util.Iterator; import java.util.Locale; import java.util.regex.Pattern; +import java.util.Arrays; @SuppressWarnings("rawtypes") public class SkriptClasses { public SkriptClasses() {} - + static { //noinspection unchecked Classes.registerClass(new ClassInfo<>(ClassInfo.class, "classinfo") @@ -73,17 +72,17 @@ public SkriptClasses() {} public ClassInfo parse(final String s, final ParseContext context) { return Classes.getClassInfoFromUserInput(Noun.stripIndefiniteArticle(s)); } - + @Override public String toString(final ClassInfo c, final int flags) { return c.toString(flags); } - + @Override public String toVariableNameString(final ClassInfo c) { return c.getCodeName(); } - + @Override public String getDebugMessage(final ClassInfo c) { return c.getCodeName(); @@ -97,17 +96,17 @@ public Fields serialize(final ClassInfo c) { f.putObject("codeName", c.getCodeName()); return f; } - + @Override public boolean canBeInstantiated() { return false; } - + @Override public void deserialize(final ClassInfo o, final Fields f) throws StreamCorruptedException { assert false; } - + @Override protected ClassInfo deserialize(final Fields fields) throws StreamCorruptedException { final String codeName = fields.getObject("codeName", String.class); @@ -118,20 +117,20 @@ protected ClassInfo deserialize(final Fields fields) throws StreamCorruptedExcep throw new StreamCorruptedException("Invalid ClassInfo " + codeName); return ci; } - + // return c.getCodeName(); @Override @Nullable public ClassInfo deserialize(final String s) { return Classes.getClassInfoNoError(s); } - + @Override public boolean mustSyncDeserialization() { return false; } })); - + Classes.registerClass(new ClassInfo<>(WeatherType.class, "weathertype") .user("weather ?types?", "weather conditions?", "weathers?") .name("Weather Type") @@ -148,12 +147,12 @@ public boolean mustSyncDeserialization() { public WeatherType parse(final String s, final ParseContext context) { return WeatherType.parse(s); } - + @Override public String toString(final WeatherType o, final int flags) { return o.toString(flags); } - + @Override public String toVariableNameString(final WeatherType o) { return "" + o.name().toLowerCase(Locale.ENGLISH); @@ -161,7 +160,7 @@ public String toVariableNameString(final WeatherType o) { }) .serializer(new EnumSerializer<>(WeatherType.class))); - + Classes.registerClass(new ClassInfo<>(ItemType.class, "itemtype") .user("item ?types?", "materials?") .name("Item Type") @@ -603,7 +602,7 @@ public String toVariableNameString(final EnchantmentType o) { .since("2.0") .parser(new Parser() { private final RegexMessage pattern = new RegexMessage("types.experience.pattern", Pattern.CASE_INSENSITIVE); - + @Override @Nullable public Experience parse(String s, final ParseContext context) { @@ -616,12 +615,12 @@ public Experience parse(String s, final ParseContext context) { return new Experience(xp); return null; } - + @Override public String toString(final Experience xp, final int flags) { return xp.toString(); } - + @Override public String toVariableNameString(final Experience xp) { return "" + xp.getXP(); @@ -658,7 +657,7 @@ public String toVariableNameString(VisualEffect e) { }) .serializer(new YggdrasilSerializer<>())); - + Classes.registerClass(new ClassInfo<>(GameruleValue.class, "gamerulevalue") .user("gamerule values?") .name("Gamerule Value") @@ -668,6 +667,31 @@ public String toVariableNameString(VisualEffect e) { .since("2.5") .serializer(new YggdrasilSerializer()) ); + + Classes.registerClass(new AnyInfo<>(AnyNamed.class, "named") + .name("Any Named Thing") + .description("Something that has a name (e.g. an item).") + .usage("") + .examples("{thing}'s name") + .since("INSERT VERSION") + ); + + Classes.registerClass(new AnyInfo<>(AnyAmount.class, "numbered") + .name("Any Numbered/Sized Thing") + .description("Something that has an amount or size.") + .usage("") + .examples("the size of {thing}", "the amount of {thing}") + .since("INSERT VERSION") + ); + + Classes.registerClass(new AnyInfo<>(AnyContains.class, "containing") + .user("any container") + .name("Anything with Contents") + .description("Something that contains other things.") + .usage("") + .examples("{a} contains {b}") + .since("INSERT VERSION") + ); } - + } diff --git a/src/main/java/ch/njol/skript/classes/registry/RegistryClassInfo.java b/src/main/java/ch/njol/skript/classes/registry/RegistryClassInfo.java index 012cbf2eb90..be7c4c8076b 100644 --- a/src/main/java/ch/njol/skript/classes/registry/RegistryClassInfo.java +++ b/src/main/java/ch/njol/skript/classes/registry/RegistryClassInfo.java @@ -66,7 +66,7 @@ public RegistryClassInfo(Class registryClass, Registry registry, String co .parser(registryParser); if (registerComparator) - Comparators.registerComparator(registryClass, registryClass, (o1, o2) -> Relation.get(o1.getKey() == o2.getKey())); + Comparators.registerComparator(registryClass, registryClass, (o1, o2) -> Relation.get(o1.getKey().equals(o2.getKey()))); } } diff --git a/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java b/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java index dc9bf9f00b7..ba35553f297 100644 --- a/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java +++ b/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.registry; import ch.njol.skript.classes.Parser; diff --git a/src/main/java/ch/njol/skript/classes/registry/RegistrySerializer.java b/src/main/java/ch/njol/skript/classes/registry/RegistrySerializer.java index 33f6645fe52..1a58d6b0912 100644 --- a/src/main/java/ch/njol/skript/classes/registry/RegistrySerializer.java +++ b/src/main/java/ch/njol/skript/classes/registry/RegistrySerializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.classes.registry; import ch.njol.skript.classes.Serializer; diff --git a/src/main/java/ch/njol/skript/command/Argument.java b/src/main/java/ch/njol/skript/command/Argument.java index c66f278d5c4..4147987b404 100644 --- a/src/main/java/ch/njol/skript/command/Argument.java +++ b/src/main/java/ch/njol/skript/command/Argument.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import java.util.WeakHashMap; diff --git a/src/main/java/ch/njol/skript/command/CommandEvent.java b/src/main/java/ch/njol/skript/command/CommandEvent.java index 07bf63ff046..803debab9f5 100644 --- a/src/main/java/ch/njol/skript/command/CommandEvent.java +++ b/src/main/java/ch/njol/skript/command/CommandEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ch/njol/skript/command/CommandHelp.java b/src/main/java/ch/njol/skript/command/CommandHelp.java index 55eea97a06e..f38a73229cf 100644 --- a/src/main/java/ch/njol/skript/command/CommandHelp.java +++ b/src/main/java/ch/njol/skript/command/CommandHelp.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import static org.bukkit.ChatColor.GRAY; diff --git a/src/main/java/ch/njol/skript/command/CommandUsage.java b/src/main/java/ch/njol/skript/command/CommandUsage.java index c746d93cf8a..8d27f74a87c 100644 --- a/src/main/java/ch/njol/skript/command/CommandUsage.java +++ b/src/main/java/ch/njol/skript/command/CommandUsage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import ch.njol.skript.lang.VariableString; diff --git a/src/main/java/ch/njol/skript/command/Commands.java b/src/main/java/ch/njol/skript/command/Commands.java index f6e448b3dad..e8c778bf559 100644 --- a/src/main/java/ch/njol/skript/command/Commands.java +++ b/src/main/java/ch/njol/skript/command/Commands.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import ch.njol.skript.ScriptLoader; @@ -77,7 +59,7 @@ public abstract class Commands { /** * A Converter flag declaring that a Converter cannot be used for parsing command arguments. */ - public static final int CONVERTER_NO_COMMAND_ARGUMENTS = 4; + public static final int CONVERTER_NO_COMMAND_ARGUMENTS = 8; private final static Map commands = new HashMap<>(); diff --git a/src/main/java/ch/njol/skript/command/EffectCommandEvent.java b/src/main/java/ch/njol/skript/command/EffectCommandEvent.java index dc411d3547d..76859f65a8d 100644 --- a/src/main/java/ch/njol/skript/command/EffectCommandEvent.java +++ b/src/main/java/ch/njol/skript/command/EffectCommandEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ch/njol/skript/command/ScriptCommand.java b/src/main/java/ch/njol/skript/command/ScriptCommand.java index 52e320c9298..e1ed5831108 100644 --- a/src/main/java/ch/njol/skript/command/ScriptCommand.java +++ b/src/main/java/ch/njol/skript/command/ScriptCommand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/command/ScriptCommandEvent.java b/src/main/java/ch/njol/skript/command/ScriptCommandEvent.java index 91b8f16567c..deed6c35be0 100644 --- a/src/main/java/ch/njol/skript/command/ScriptCommandEvent.java +++ b/src/main/java/ch/njol/skript/command/ScriptCommandEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.command; import ch.njol.skript.effects.Delay; diff --git a/src/main/java/ch/njol/skript/conditions/CondAI.java b/src/main/java/ch/njol/skript/conditions/CondAI.java index 52370cd07a3..4e4b602f4f7 100644 --- a/src/main/java/ch/njol/skript/conditions/CondAI.java +++ b/src/main/java/ch/njol/skript/conditions/CondAI.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/conditions/CondAlphanumeric.java b/src/main/java/ch/njol/skript/conditions/CondAlphanumeric.java index d52713979c6..01702442428 100644 --- a/src/main/java/ch/njol/skript/conditions/CondAlphanumeric.java +++ b/src/main/java/ch/njol/skript/conditions/CondAlphanumeric.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.apache.commons.lang.StringUtils; diff --git a/src/main/java/ch/njol/skript/conditions/CondAnchorWorks.java b/src/main/java/ch/njol/skript/conditions/CondAnchorWorks.java index a6c1aafacb1..03768c63793 100644 --- a/src/main/java/ch/njol/skript/conditions/CondAnchorWorks.java +++ b/src/main/java/ch/njol/skript/conditions/CondAnchorWorks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondCanFly.java b/src/main/java/ch/njol/skript/conditions/CondCanFly.java index 478c0e862d4..efbd07272d4 100644 --- a/src/main/java/ch/njol/skript/conditions/CondCanFly.java +++ b/src/main/java/ch/njol/skript/conditions/CondCanFly.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondCanHold.java b/src/main/java/ch/njol/skript/conditions/CondCanHold.java index 8705c325a81..bfbcd70af9e 100644 --- a/src/main/java/ch/njol/skript/conditions/CondCanHold.java +++ b/src/main/java/ch/njol/skript/conditions/CondCanHold.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondCanPickUpItems.java b/src/main/java/ch/njol/skript/conditions/CondCanPickUpItems.java index 07f5735e4f9..1bfb6d0aeac 100644 --- a/src/main/java/ch/njol/skript/conditions/CondCanPickUpItems.java +++ b/src/main/java/ch/njol/skript/conditions/CondCanPickUpItems.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.conditions.base.PropertyCondition; diff --git a/src/main/java/ch/njol/skript/conditions/CondCancelled.java b/src/main/java/ch/njol/skript/conditions/CondCancelled.java index 4fcf70dfd03..29e98ae3c54 100644 --- a/src/main/java/ch/njol/skript/conditions/CondCancelled.java +++ b/src/main/java/ch/njol/skript/conditions/CondCancelled.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondChance.java b/src/main/java/ch/njol/skript/conditions/CondChance.java index 88359eb4867..1b2326adafb 100644 --- a/src/main/java/ch/njol/skript/conditions/CondChance.java +++ b/src/main/java/ch/njol/skript/conditions/CondChance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondCompare.java b/src/main/java/ch/njol/skript/conditions/CondCompare.java index e17cb31e861..bcdc9556de9 100644 --- a/src/main/java/ch/njol/skript/conditions/CondCompare.java +++ b/src/main/java/ch/njol/skript/conditions/CondCompare.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.lang.VerboseAssert; diff --git a/src/main/java/ch/njol/skript/conditions/CondContains.java b/src/main/java/ch/njol/skript/conditions/CondContains.java index 0c54c1be88d..366141ae0b3 100644 --- a/src/main/java/ch/njol/skript/conditions/CondContains.java +++ b/src/main/java/ch/njol/skript/conditions/CondContains.java @@ -1,26 +1,9 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; import ch.njol.skript.SkriptConfig; import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.lang.util.common.AnyContains; import org.skriptlang.skript.lang.comparator.Relation; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; @@ -36,14 +19,16 @@ import org.bukkit.event.Event; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.skriptlang.skript.lang.converter.Converters; import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.Objects; @Name("Contains") -@Description("Checks whether an inventory contains an item, a text contains another piece of text, " + - "or a list (e.g. {list variable::*} or 'drops') contains another object.") +@Description("Checks whether an inventory contains an item, a text contains another piece of text, " + + "a container contains something, " + + "or a list (e.g. {list variable::*} or 'drops') contains another object.") @Examples({"block contains 20 cobblestone", "player has 4 flint and 2 iron ingots", "{list::*} contains 5"}) @@ -63,16 +48,13 @@ public class CondContains extends Condition { * The type of check to perform */ private enum CheckType { - STRING, INVENTORY, OBJECTS, UNKNOWN + STRING, INVENTORY, OBJECTS, UNKNOWN, CONTAINER } - @SuppressWarnings("NotNullFieldNotInitialized") private Expression containers; - @SuppressWarnings("NotNullFieldNotInitialized") private Expression items; private boolean explicitSingle; - @SuppressWarnings("NotNullFieldNotInitialized") private CheckType checkType; @Override @@ -88,15 +70,15 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye checkType = CheckType.UNKNOWN; } - setNegated(matchedPattern % 2 == 1); + this.setNegated(matchedPattern % 2 == 1); return true; } @Override - public boolean check(Event e) { + public boolean check(Event event) { CheckType checkType = this.checkType; - Object[] containerValues = containers.getAll(e); + Object[] containerValues = containers.getAll(event); if (containerValues.length == 0) return isNegated(); @@ -106,6 +88,11 @@ public boolean check(Event e) { if (Arrays.stream(containerValues) .allMatch(Inventory.class::isInstance)) { checkType = CheckType.INVENTORY; + } else if (explicitSingle + && Arrays.stream(containerValues) + .allMatch(object -> object instanceof AnyContains + || Converters.converterExists(object.getClass(), AnyContains.class))) { + checkType = CheckType.CONTAINER; } else if (explicitSingle && Arrays.stream(containerValues) .allMatch(String.class::isInstance)) { @@ -115,48 +102,60 @@ public boolean check(Event e) { } } - if (checkType == CheckType.INVENTORY) { - return SimpleExpression.check(containerValues, o -> { + return switch (checkType) { + case INVENTORY -> SimpleExpression.check(containerValues, o -> { Inventory inventory = (Inventory) o; - return items.check(e, o1 -> { - if (o1 instanceof ItemType) - return ((ItemType) o1).isContainedIn(inventory); - else if (o1 instanceof ItemStack) - return inventory.containsAtLeast((ItemStack) o1, ((ItemStack) o1).getAmount()); - else if (o1 instanceof Inventory) + return items.check(event, o1 -> { + if (o1 instanceof ItemType type) { + return type.isContainedIn(inventory); + } else if (o1 instanceof ItemStack stack) { + return inventory.containsAtLeast(stack, stack.getAmount()); + } else if (o1 instanceof Inventory) { return Objects.equals(inventory, o1); - else - return false; - }); - }, isNegated(), containers.getAnd()); - } else if (checkType == CheckType.STRING) { - boolean caseSensitive = SkriptConfig.caseSensitive.value(); - - return SimpleExpression.check(containerValues, o -> { - String string = (String) o; - - return items.check(e, o1 -> { - if (o1 instanceof String) { - return StringUtils.contains(string, (String) o1, caseSensitive); - } else { - return false; } + return false; }); }, isNegated(), containers.getAnd()); - } else { - assert checkType == CheckType.OBJECTS; - - return items.check(e, o1 -> { - for (Object o2 : containerValues) { - if (Comparators.compare(o1, o2) == Relation.EQUAL) - return true; + case STRING -> { + boolean caseSensitive = SkriptConfig.caseSensitive.value(); + + yield SimpleExpression.check(containerValues, o -> { + String string = (String) o; + + return items.check(event, o1 -> { + if (o1 instanceof String text) { + return StringUtils.contains(string, text, caseSensitive); + } else { + return false; + } + }); + }, isNegated(), containers.getAnd()); + } + case CONTAINER -> SimpleExpression.check(containerValues, object -> { + AnyContains container; + if (object instanceof AnyContains) { + container = (AnyContains) object; + } else { + container = Converters.convert(object, AnyContains.class); } - return false; - }, isNegated()); - } + if (container == null) + return false; + return items.check(event, container::checkSafely); + }, isNegated(), containers.getAnd()); + default -> { + assert checkType == CheckType.OBJECTS; + yield items.check(event, o1 -> { + for (Object o2 : containerValues) { + if (Comparators.compare(o1, o2) == Relation.EQUAL) + return true; + } + return false; + }, isNegated()); + } + }; } - + @Override public String toString(@Nullable Event e, boolean debug) { return containers.toString(e, debug) + (isNegated() ? " doesn't contain " : " contains ") + items.toString(e, debug); diff --git a/src/main/java/ch/njol/skript/conditions/CondDamageCause.java b/src/main/java/ch/njol/skript/conditions/CondDamageCause.java index 59c6421af77..53cda6b0c00 100644 --- a/src/main/java/ch/njol/skript/conditions/CondDamageCause.java +++ b/src/main/java/ch/njol/skript/conditions/CondDamageCause.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondDate.java b/src/main/java/ch/njol/skript/conditions/CondDate.java index 7172e9e80b1..47a20522fb3 100644 --- a/src/main/java/ch/njol/skript/conditions/CondDate.java +++ b/src/main/java/ch/njol/skript/conditions/CondDate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondElytraBoostConsume.java b/src/main/java/ch/njol/skript/conditions/CondElytraBoostConsume.java new file mode 100644 index 00000000000..ed971a3aed2 --- /dev/null +++ b/src/main/java/ch/njol/skript/conditions/CondElytraBoostConsume.java @@ -0,0 +1,56 @@ +package ch.njol.skript.conditions; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.*; +import ch.njol.skript.lang.Condition; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +@Name("Will Consume Boosting Firework") +@Description("Checks to see if the firework used in an 'elytra boost' event will be consumed.") +@Examples({ + "on elytra boost:", + "\tif the used firework will be consumed:", + "\t\tprevent the used firework from being consume" +}) +@RequiredPlugins("Paper") +@Since("INSERT VERSION") +public class CondElytraBoostConsume extends Condition { + + static { + if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) { + Skript.registerCondition(CondElytraBoostConsume.class, + "[the] (boosting|used) firework will be consumed", + "[the] (boosting|used) firework (will not|won't) be consumed"); + } + } + + private boolean checkConsume; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + if (!getParser().isCurrentEvent(PlayerElytraBoostEvent.class)) { + Skript.error("This condition can only be used in an 'elytra boost' event."); + return false; + } + checkConsume = matchedPattern == 0; + return true; + } + + @Override + public boolean check(Event event) { + if (!(event instanceof PlayerElytraBoostEvent boostEvent)) + return false; + return boostEvent.shouldConsume() == checkConsume; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "the boosting firework will " + (checkConsume ? "" : "not") + " be consumed"; + } + +} diff --git a/src/main/java/ch/njol/skript/conditions/CondEntityIsInLiquid.java b/src/main/java/ch/njol/skript/conditions/CondEntityIsInLiquid.java index c2f838e148c..d470d0b14e8 100644 --- a/src/main/java/ch/njol/skript/conditions/CondEntityIsInLiquid.java +++ b/src/main/java/ch/njol/skript/conditions/CondEntityIsInLiquid.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondEntityIsWet.java b/src/main/java/ch/njol/skript/conditions/CondEntityIsWet.java index e013696582b..4b1dd579236 100644 --- a/src/main/java/ch/njol/skript/conditions/CondEntityIsWet.java +++ b/src/main/java/ch/njol/skript/conditions/CondEntityIsWet.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondGlowingText.java b/src/main/java/ch/njol/skript/conditions/CondGlowingText.java index aaf14939305..f7d42248377 100644 --- a/src/main/java/ch/njol/skript/conditions/CondGlowingText.java +++ b/src/main/java/ch/njol/skript/conditions/CondGlowingText.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasClientWeather.java b/src/main/java/ch/njol/skript/conditions/CondHasClientWeather.java index e9284a38807..0719ebf94ac 100755 --- a/src/main/java/ch/njol/skript/conditions/CondHasClientWeather.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasClientWeather.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasCustomModelData.java b/src/main/java/ch/njol/skript/conditions/CondHasCustomModelData.java index 98f86424826..66621f9e91b 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasCustomModelData.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasCustomModelData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.inventory.meta.ItemMeta; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasItemCooldown.java b/src/main/java/ch/njol/skript/conditions/CondHasItemCooldown.java index 9e1d1fcf4db..dd67a64d6fc 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasItemCooldown.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasItemCooldown.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasLineOfSight.java b/src/main/java/ch/njol/skript/conditions/CondHasLineOfSight.java index 706fa4f8629..b5e8dae5571 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasLineOfSight.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasLineOfSight.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasMetadata.java b/src/main/java/ch/njol/skript/conditions/CondHasMetadata.java index 876a74249f8..cfb60086fd5 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasMetadata.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasMetadata.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasPotion.java b/src/main/java/ch/njol/skript/conditions/CondHasPotion.java index 41aa7fa55c8..b71b6298d27 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasPotion.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasPotion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasResourcePack.java b/src/main/java/ch/njol/skript/conditions/CondHasResourcePack.java index 3d0eda99ef0..1b944f97134 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasResourcePack.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasResourcePack.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondHasScoreboardTag.java b/src/main/java/ch/njol/skript/conditions/CondHasScoreboardTag.java index 0fe7942cf62..db7ffd61df4 100644 --- a/src/main/java/ch/njol/skript/conditions/CondHasScoreboardTag.java +++ b/src/main/java/ch/njol/skript/conditions/CondHasScoreboardTag.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/conditions/CondIgnitionProcess.java b/src/main/java/ch/njol/skript/conditions/CondIgnitionProcess.java index e0d0f1849c9..f59bc77a819 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIgnitionProcess.java +++ b/src/main/java/ch/njol/skript/conditions/CondIgnitionProcess.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Creeper; diff --git a/src/main/java/ch/njol/skript/conditions/CondIncendiary.java b/src/main/java/ch/njol/skript/conditions/CondIncendiary.java index a4d47b012ac..5ee20c07cec 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIncendiary.java +++ b/src/main/java/ch/njol/skript/conditions/CondIncendiary.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsAlive.java b/src/main/java/ch/njol/skript/conditions/CondIsAlive.java index 714b0ae5953..5026d5199ab 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsAlive.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsAlive.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsBanned.java b/src/main/java/ch/njol/skript/conditions/CondIsBanned.java index 212da063416..37fc818c2ac 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsBanned.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsBanned.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import java.net.InetSocketAddress; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsBlock.java b/src/main/java/ch/njol/skript/conditions/CondIsBlock.java index efafb2583b7..ee4035336b4 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsBlock.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsBlockRedstonePowered.java b/src/main/java/ch/njol/skript/conditions/CondIsBlockRedstonePowered.java index b7ec7be8027..86cba581c0e 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsBlockRedstonePowered.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsBlockRedstonePowered.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.block.Block; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsBlocking.java b/src/main/java/ch/njol/skript/conditions/CondIsBlocking.java index 6d81a2633a6..684c3c38370 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsBlocking.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsBlocking.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsBurning.java b/src/main/java/ch/njol/skript/conditions/CondIsBurning.java index b1b42efa5e0..f2e7838edf8 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsBurning.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsBurning.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsClimbing.java b/src/main/java/ch/njol/skript/conditions/CondIsClimbing.java index 48cdfe5eb40..0acb7ffeeba 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsClimbing.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsClimbing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsEdible.java b/src/main/java/ch/njol/skript/conditions/CondIsEdible.java index 8545da529f9..d386c321a0f 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsEdible.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsEdible.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsEmpty.java b/src/main/java/ch/njol/skript/conditions/CondIsEmpty.java index 972f38ed5d3..d3eb1825c3e 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsEmpty.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsEmpty.java @@ -1,70 +1,51 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; -import org.bukkit.Material; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - import ch.njol.skript.conditions.base.PropertyCondition; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Name; import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.util.common.AnyAmount; import ch.njol.skript.util.slot.Slot; +import org.bukkit.Material; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; -/** - * @author Peter Güttinger - */ @Name("Is Empty") @Description("Checks whether an inventory, an inventory slot, or a text is empty.") @Examples("player's inventory is empty") @Since("unknown (before 2.1)") public class CondIsEmpty extends PropertyCondition { - + static { - register(CondIsEmpty.class, "empty", "inventories/slots/strings"); + register(CondIsEmpty.class, "empty", "inventories/slots/strings/numbered"); } - + @Override - public boolean check(final Object o) { - if (o instanceof String) - return ((String) o).isEmpty(); - if (o instanceof Inventory) { - for (ItemStack s : ((Inventory) o).getContents()) { - if (s != null && s.getType() != Material.AIR) + public boolean check(Object object) { + if (object instanceof String string) + return string.isEmpty(); + if (object instanceof Inventory inventory) { + for (ItemStack item : inventory.getContents()) { + if (item != null && item.getType() != Material.AIR) return false; // There is an item here! } return true; } - if (o instanceof Slot) { - final Slot s = (Slot) o; - final ItemStack i = s.getItem(); - return i == null || i.getType() == Material.AIR; + if (object instanceof Slot slot) { + final ItemStack item = slot.getItem(); + return item == null || item.getType() == Material.AIR; + } + if (object instanceof AnyAmount numbered) { + return numbered.isEmpty(); } assert false; return false; } - + @Override protected String getPropertyName() { return "empty"; } - + } diff --git a/src/main/java/ch/njol/skript/conditions/CondIsEnchanted.java b/src/main/java/ch/njol/skript/conditions/CondIsEnchanted.java index b3fd13273f4..d0068b6c518 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsEnchanted.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsEnchanted.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java index e52d8f08992..da0768b35d3 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFlammable.java b/src/main/java/ch/njol/skript/conditions/CondIsFlammable.java index aafc79a6900..778a37c7dee 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFlammable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFlammable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFlying.java b/src/main/java/ch/njol/skript/conditions/CondIsFlying.java index d917ac4f612..bc1d831dba7 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFlying.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFlying.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFrozen.java b/src/main/java/ch/njol/skript/conditions/CondIsFrozen.java index d32cef4ec4e..ed5a511d875 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFrozen.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFrozen.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFuel.java b/src/main/java/ch/njol/skript/conditions/CondIsFuel.java index fd921af54a4..07f8ed9df1f 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFuel.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFuel.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsGliding.java b/src/main/java/ch/njol/skript/conditions/CondIsGliding.java index 36dc35f6dae..d5224690bdd 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsGliding.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsGliding.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsHandRaised.java b/src/main/java/ch/njol/skript/conditions/CondIsHandRaised.java index 7a6686171fc..cc9d617f08b 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsHandRaised.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsHandRaised.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsInfinite.java b/src/main/java/ch/njol/skript/conditions/CondIsInfinite.java index 725480bac1b..ceea3976c7d 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsInfinite.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsInfinite.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.potion.PotionEffect; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsInteractable.java b/src/main/java/ch/njol/skript/conditions/CondIsInteractable.java index 4cc58208a2f..d699204c024 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsInteractable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsInteractable.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsInvisible.java b/src/main/java/ch/njol/skript/conditions/CondIsInvisible.java index baa1fec0492..a839313e34d 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsInvisible.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsInvisible.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java b/src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java index 9978926e108..3e957157e0d 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsJumping.java b/src/main/java/ch/njol/skript/conditions/CondIsJumping.java index fb3738a05c6..41b766e9f59 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsJumping.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsJumping.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.conditions.base.PropertyCondition; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsLeftHanded.java b/src/main/java/ch/njol/skript/conditions/CondIsLeftHanded.java index 7101ad18b92..178a7b75425 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsLeftHanded.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsLeftHanded.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsLoaded.java b/src/main/java/ch/njol/skript/conditions/CondIsLoaded.java index 79158467187..5e4ba116917 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsLoaded.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsLoaded.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsOccluding.java b/src/main/java/ch/njol/skript/conditions/CondIsOccluding.java index 9e0b04bc975..1367e183c4b 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsOccluding.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsOccluding.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsOfType.java b/src/main/java/ch/njol/skript/conditions/CondIsOfType.java index 3a41d9881b9..f3c18f3fa4f 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsOfType.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsOfType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsOnGround.java b/src/main/java/ch/njol/skript/conditions/CondIsOnGround.java index c557d0561f2..fc7e327f690 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsOnGround.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsOnGround.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsOnline.java b/src/main/java/ch/njol/skript/conditions/CondIsOnline.java index 6f3f22e40c5..98eee7e0c07 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsOnline.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsOnline.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsOp.java b/src/main/java/ch/njol/skript/conditions/CondIsOp.java index 22304c3e589..63b0d24476e 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsOp.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsOp.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.conditions.base.PropertyCondition; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsPassable.java b/src/main/java/ch/njol/skript/conditions/CondIsPassable.java index 2e6da4e7e26..200d442c6a2 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsPassable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsPassable.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.block.Block; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsPathfinding.java b/src/main/java/ch/njol/skript/conditions/CondIsPathfinding.java index 8a6768baefa..7c4fd18183c 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsPathfinding.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsPathfinding.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsPluginEnabled.java b/src/main/java/ch/njol/skript/conditions/CondIsPluginEnabled.java index b80c6f7321b..e6d60df64d9 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsPluginEnabled.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsPluginEnabled.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsPoisoned.java b/src/main/java/ch/njol/skript/conditions/CondIsPoisoned.java index 3f65f35ac83..89f85cacf02 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsPoisoned.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsPoisoned.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsPreferredTool.java b/src/main/java/ch/njol/skript/conditions/CondIsPreferredTool.java index 04dbca4e938..945f10c05cd 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsPreferredTool.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsPreferredTool.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsResonating.java b/src/main/java/ch/njol/skript/conditions/CondIsResonating.java index 0e255b87e16..ab6bef9e2dc 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsResonating.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsResonating.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsRiding.java b/src/main/java/ch/njol/skript/conditions/CondIsRiding.java index 77567db83dd..d62b58fcd73 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsRiding.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsRiding.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsRinging.java b/src/main/java/ch/njol/skript/conditions/CondIsRinging.java index 49bda5d6672..68c1e5b4fcd 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsRinging.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsRinging.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsRiptiding.java b/src/main/java/ch/njol/skript/conditions/CondIsRiptiding.java index e0d9d1c3b8a..ef891f4e065 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsRiptiding.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsRiptiding.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSet.java b/src/main/java/ch/njol/skript/conditions/CondIsSet.java index 0433476833a..f6afc2e5a6a 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSet.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSet.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.lang.VerboseAssert; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSheared.java b/src/main/java/ch/njol/skript/conditions/CondIsSheared.java index a000891be95..99f4fb6b138 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSheared.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSheared.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSilent.java b/src/main/java/ch/njol/skript/conditions/CondIsSilent.java index 64a7c67e2d4..46078b7b9c7 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSilent.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSilent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSkriptCommand.java b/src/main/java/ch/njol/skript/conditions/CondIsSkriptCommand.java index 4c4f8097ba4..ea6a21305c4 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSkriptCommand.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSkriptCommand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import static ch.njol.skript.command.Commands.scriptCommandExists; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSleeping.java b/src/main/java/ch/njol/skript/conditions/CondIsSleeping.java index 9ac5791ce8b..d253829b89d 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSleeping.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSleeping.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java b/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java index 1b71258482b..c8528b1bb43 100755 --- a/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import java.util.Random; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSneaking.java b/src/main/java/ch/njol/skript/conditions/CondIsSneaking.java index 9e1e4a83458..532ed58214b 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSneaking.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSneaking.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSolid.java b/src/main/java/ch/njol/skript/conditions/CondIsSolid.java index 67576570004..940672e82fc 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSolid.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSolid.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSprinting.java b/src/main/java/ch/njol/skript/conditions/CondIsSprinting.java index e06b0fa289f..c1f25ea82e2 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSprinting.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSprinting.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsStackable.java b/src/main/java/ch/njol/skript/conditions/CondIsStackable.java index 1db6e77a4f1..ed111e43436 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsStackable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsStackable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsSwimming.java b/src/main/java/ch/njol/skript/conditions/CondIsSwimming.java index c469e8e4650..ef340e17f21 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsSwimming.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsSwimming.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsTameable.java b/src/main/java/ch/njol/skript/conditions/CondIsTameable.java index 557cddf080f..b7e55382673 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsTameable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsTameable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsTransparent.java b/src/main/java/ch/njol/skript/conditions/CondIsTransparent.java index bbb68125157..16a5b68a8d6 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsTransparent.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsTransparent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsUnbreakable.java b/src/main/java/ch/njol/skript/conditions/CondIsUnbreakable.java index 5a0a7d4cd58..4f8f47e3ae1 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsUnbreakable.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsUnbreakable.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsUsingFeature.java b/src/main/java/ch/njol/skript/conditions/CondIsUsingFeature.java index 39a23b740ab..58302c07a74 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsUsingFeature.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsUsingFeature.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsValid.java b/src/main/java/ch/njol/skript/conditions/CondIsValid.java index a22e7f05b0e..7d3b3d88b37 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsValid.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsValid.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsVectorNormalized.java b/src/main/java/ch/njol/skript/conditions/CondIsVectorNormalized.java index a93d02afa19..ce8444e26ae 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsVectorNormalized.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsVectorNormalized.java @@ -1,21 +1,3 @@ -/** -* This file is part of Skript. -* -* Skript is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Skript is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Skript. If not, see . -* -* Copyright Peter Güttinger, SkriptLang team and contributors -*/ package ch.njol.skript.conditions; import org.bukkit.util.Vector; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsWhitelisted.java b/src/main/java/ch/njol/skript/conditions/CondIsWhitelisted.java index deac66def49..6b45817e3a8 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsWhitelisted.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsWhitelisted.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondIsWithin.java b/src/main/java/ch/njol/skript/conditions/CondIsWithin.java index 7ec25401ae8..9631a598a33 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsWithin.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsWithin.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondItemEnchantmentGlint.java b/src/main/java/ch/njol/skript/conditions/CondItemEnchantmentGlint.java new file mode 100644 index 00000000000..0b3f20d894c --- /dev/null +++ b/src/main/java/ch/njol/skript/conditions/CondItemEnchantmentGlint.java @@ -0,0 +1,64 @@ +package ch.njol.skript.conditions; + +import org.bukkit.inventory.meta.ItemMeta; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.conditions.base.PropertyCondition; +import ch.njol.skript.doc.*; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; + +@Name("Item Has Enchantment Glint Override") +@Description("Checks whether an item has the enchantment glint overridden, or is forced to glint or not.") +@Examples({ + "if the player's tool has the enchantment glint override", + "\tsend \"Your tool has the enchantment glint override.\" to player", + "", + "if {_item} is forced to glint:", + "\tsend \"This item is forced to glint.\" to player", + "else if {_item} is forced to not glint:", + "\tsend \"This item is forced to not glint.\" to player", + "else:", + "\tsend \"This item does not have any glint override.\" to player" +}) +@RequiredPlugins("Spigot 1.20.5+") +@Since("INSERT VERSION") +public class CondItemEnchantmentGlint extends PropertyCondition { + + static { + if (Skript.methodExists(ItemMeta.class, "getEnchantmentGlintOverride")) { + register(CondItemEnchantmentGlint.class, PropertyType.HAVE, "enchantment glint overrid(den|e)", "itemtypes"); + register(CondItemEnchantmentGlint.class, PropertyType.BE, "forced to [:not] glint", "itemtypes"); + } + } + + private int matchedPattern; + + @Override + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + this.matchedPattern = matchedPattern; + return super.init(expressions, matchedPattern, isDelayed, parseResult); + } + + @Override + public boolean check(ItemType itemType) { + ItemMeta meta = itemType.getItemMeta(); + // enchantment glint override + if (matchedPattern == 0) + return meta.hasEnchantmentGlintOverride(); + // forced to glint + if (!meta.hasEnchantmentGlintOverride()) + return false; + return meta.getEnchantmentGlintOverride(); + } + + @Override + protected String getPropertyName() { + if (matchedPattern == 0) + return "enchantment glint overridden"; + return "forced to " + (isNegated() ? "not " : "") + "glint"; + } + +} diff --git a/src/main/java/ch/njol/skript/conditions/CondItemInHand.java b/src/main/java/ch/njol/skript/conditions/CondItemInHand.java index cdad86ce133..68bf091628b 100644 --- a/src/main/java/ch/njol/skript/conditions/CondItemInHand.java +++ b/src/main/java/ch/njol/skript/conditions/CondItemInHand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondLeashed.java b/src/main/java/ch/njol/skript/conditions/CondLeashed.java index 9e9978623a2..f2fb1fa887d 100644 --- a/src/main/java/ch/njol/skript/conditions/CondLeashed.java +++ b/src/main/java/ch/njol/skript/conditions/CondLeashed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.conditions.base.PropertyCondition; diff --git a/src/main/java/ch/njol/skript/conditions/CondMatches.java b/src/main/java/ch/njol/skript/conditions/CondMatches.java index f00c92950e9..6ce5facb581 100644 --- a/src/main/java/ch/njol/skript/conditions/CondMatches.java +++ b/src/main/java/ch/njol/skript/conditions/CondMatches.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; diff --git a/src/main/java/ch/njol/skript/conditions/CondMinecraftVersion.java b/src/main/java/ch/njol/skript/conditions/CondMinecraftVersion.java index 0d93396f18b..682b6a144cd 100644 --- a/src/main/java/ch/njol/skript/conditions/CondMinecraftVersion.java +++ b/src/main/java/ch/njol/skript/conditions/CondMinecraftVersion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondPermission.java b/src/main/java/ch/njol/skript/conditions/CondPermission.java index ed5ac0f6cb2..c6494171c22 100644 --- a/src/main/java/ch/njol/skript/conditions/CondPermission.java +++ b/src/main/java/ch/njol/skript/conditions/CondPermission.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ch/njol/skript/conditions/CondPlayedBefore.java b/src/main/java/ch/njol/skript/conditions/CondPlayedBefore.java index ef8a19fbfc1..ba2c1e611a9 100644 --- a/src/main/java/ch/njol/skript/conditions/CondPlayedBefore.java +++ b/src/main/java/ch/njol/skript/conditions/CondPlayedBefore.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondPvP.java b/src/main/java/ch/njol/skript/conditions/CondPvP.java index 5aff13b8964..250f38fd538 100644 --- a/src/main/java/ch/njol/skript/conditions/CondPvP.java +++ b/src/main/java/ch/njol/skript/conditions/CondPvP.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.World; diff --git a/src/main/java/ch/njol/skript/conditions/CondResourcePack.java b/src/main/java/ch/njol/skript/conditions/CondResourcePack.java index c987e54f43a..1d1c208766c 100644 --- a/src/main/java/ch/njol/skript/conditions/CondResourcePack.java +++ b/src/main/java/ch/njol/skript/conditions/CondResourcePack.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondRespawnLocation.java b/src/main/java/ch/njol/skript/conditions/CondRespawnLocation.java index 7a586cc09b8..56199bea961 100644 --- a/src/main/java/ch/njol/skript/conditions/CondRespawnLocation.java +++ b/src/main/java/ch/njol/skript/conditions/CondRespawnLocation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondScriptLoaded.java b/src/main/java/ch/njol/skript/conditions/CondScriptLoaded.java index cf3c97cd9d1..9212ae3356a 100644 --- a/src/main/java/ch/njol/skript/conditions/CondScriptLoaded.java +++ b/src/main/java/ch/njol/skript/conditions/CondScriptLoaded.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/conditions/CondStartsEndsWith.java b/src/main/java/ch/njol/skript/conditions/CondStartsEndsWith.java index 9bdea38c61b..205db7eca53 100644 --- a/src/main/java/ch/njol/skript/conditions/CondStartsEndsWith.java +++ b/src/main/java/ch/njol/skript/conditions/CondStartsEndsWith.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/conditions/CondTooltip.java b/src/main/java/ch/njol/skript/conditions/CondTooltip.java index b7ee0c928bd..7f84be363a4 100644 --- a/src/main/java/ch/njol/skript/conditions/CondTooltip.java +++ b/src/main/java/ch/njol/skript/conditions/CondTooltip.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondWillHatch.java b/src/main/java/ch/njol/skript/conditions/CondWillHatch.java index 14f5ddcc3f0..dfdc5d4854c 100644 --- a/src/main/java/ch/njol/skript/conditions/CondWillHatch.java +++ b/src/main/java/ch/njol/skript/conditions/CondWillHatch.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/CondWithinRadius.java b/src/main/java/ch/njol/skript/conditions/CondWithinRadius.java index b422e622b95..d11a2add4bd 100644 --- a/src/main/java/ch/njol/skript/conditions/CondWithinRadius.java +++ b/src/main/java/ch/njol/skript/conditions/CondWithinRadius.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/conditions/base/PropertyCondition.java b/src/main/java/ch/njol/skript/conditions/base/PropertyCondition.java index 9a71bbb79b3..d539273f252 100644 --- a/src/main/java/ch/njol/skript/conditions/base/PropertyCondition.java +++ b/src/main/java/ch/njol/skript/conditions/base/PropertyCondition.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.conditions.base; import org.bukkit.event.Event; @@ -28,6 +10,10 @@ import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Checker; import ch.njol.util.Kleenean; +import org.jetbrains.annotations.ApiStatus; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Priority; /** * This class can be used for an easier writing of conditions that contain only one type in the pattern, @@ -54,6 +40,14 @@ */ public abstract class PropertyCondition extends Condition implements Checker { + /** + * A priority for {@link PropertyCondition}s. + * They will be registered before {@link SyntaxInfo#PATTERN_MATCHES_EVERYTHING} expressions + * but after {@link SyntaxInfo#COMBINED} expressions. + */ + @ApiStatus.Experimental + public static final Priority DEFAULT_PRIORITY = Priority.before(SyntaxInfo.PATTERN_MATCHES_EVERYTHING); + /** * See {@link PropertyCondition} for more info */ @@ -83,55 +77,106 @@ public enum PropertyType { WILL } - private Expression expr; + /** + * @param registry The SyntaxRegistry to register with. + * @param condition The class to register + * @param property The property name, for example fly in players can fly + * @param type Must be plural, for example players in players can fly + * @param The Condition type. + * @return The registered {@link SyntaxInfo}. + */ + @ApiStatus.Experimental + public static SyntaxInfo register(SyntaxRegistry registry, Class condition, String property, String type) { + return register(registry, condition, PropertyType.BE, property, type); + } /** + * @param registry The SyntaxRegistry to register with. + * @param condition The class to register + * @param propertyType The property type, see {@link PropertyType} + * @param property The property name, for example fly in players can fly + * @param type Must be plural, for example players in players can fly + * @param The Condition type. + * @return The registered {@link SyntaxInfo}. + */ + @ApiStatus.Experimental + public static SyntaxInfo register(SyntaxRegistry registry, Class condition, PropertyType propertyType, String property, String type) { + if (type.contains("%")) + throw new SkriptAPIException("The type argument must not contain any '%'s"); + SyntaxInfo.Builder builder = SyntaxInfo.builder(condition).priority(DEFAULT_PRIORITY); + switch (propertyType) { + case BE -> builder.addPatterns("%" + type + "% (is|are) " + property, + "%" + type + "% (isn't|is not|aren't|are not) " + property); + case CAN -> builder.addPatterns("%" + type + "% can " + property, + "%" + type + "% (can't|cannot|can not) " + property); + case HAVE -> builder.addPatterns("%" + type + "% (has|have) " + property, + "%" + type + "% (doesn't|does not|do not|don't) have " + property); + case WILL -> builder.addPatterns("%" + type + "% will " + property, + "%" + type + "% (will (not|neither)|won't) " + property); + } + SyntaxInfo info = builder.build(); + registry.register(SyntaxRegistry.CONDITION, info); + return info; + } + + /** + * Registers a new property condition. The property type is set to {@link PropertyType#BE}. + * * @param condition the class to register * @param property the property name, for example fly in players can fly * @param type must be plural, for example players in players can fly */ - public static void register(Class condition, String property, String type) { register(condition, PropertyType.BE, property, type); } /** + * Registers a new property condition. + * * @param condition the class to register * @param propertyType the property type, see {@link PropertyType} * @param property the property name, for example fly in players can fly * @param type must be plural, for example players in players can fly */ - public static void register(Class condition, PropertyType propertyType, String property, String type) { + Skript.registerCondition(condition, ConditionType.PROPERTY, + getPatterns(propertyType, property, type)); + } + + /** + * Returns the patterns for the given property type, property and type. + * + * @param propertyType the property type, see {@link PropertyType} + * @param property the property name, for example fly in players can fly + * @param type must be plural, for example players in players can fly + * @return patterns formmated for {@link Skript#registerCondition(Class, String...)} + */ + public static String[] getPatterns(PropertyType propertyType, String property, String type) { if (type.contains("%")) throw new SkriptAPIException("The type argument must not contain any '%'s"); - switch (propertyType) { - case BE: - Skript.registerCondition(condition, ConditionType.PROPERTY, - "%" + type + "% (is|are) " + property, - "%" + type + "% (isn't|is not|aren't|are not) " + property); - break; - case CAN: - Skript.registerCondition(condition, ConditionType.PROPERTY, - "%" + type + "% can " + property, - "%" + type + "% (can't|cannot|can not) " + property); - break; - case HAVE: - Skript.registerCondition(condition, ConditionType.PROPERTY, - "%" + type + "% (has|have) " + property, - "%" + type + "% (doesn't|does not|do not|don't) have " + property); - break; - case WILL: - Skript.registerCondition(condition, - "%" + type + "% will " + property, - "%" + type + "% (will (not|neither)|won't) " + property); - break; - default: - assert false; - } + return switch (propertyType) { + case BE -> new String[] { + "%" + type + "% (is|are) " + property, + "%" + type + "% (isn't|is not|aren't|are not) " + property + }; + case CAN -> new String[] { + "%" + type + "% can " + property, + "%" + type + "% (can't|cannot|can not) " + property + }; + case HAVE -> new String[] { + "%" + type + "% (has|have) " + property, + "%" + type + "% (doesn't|does not|do not|don't) have " + property + }; + case WILL -> new String[] { + "%" + type + "% will " + property, + "%" + type + "% (will (not|neither)|won't) " + property + }; + }; } + private Expression expr; + @Override @SuppressWarnings("unchecked") public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { diff --git a/src/main/java/ch/njol/skript/config/Config.java b/src/main/java/ch/njol/skript/config/Config.java index 621a12b1a17..c8ffbe70e4a 100644 --- a/src/main/java/ch/njol/skript/config/Config.java +++ b/src/main/java/ch/njol/skript/config/Config.java @@ -1,27 +1,12 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import ch.njol.skript.Skript; import ch.njol.skript.config.validate.SectionValidator; +import com.google.common.base.Preconditions; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -30,48 +15,44 @@ import java.lang.reflect.Modifier; import java.nio.channels.Channels; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.HashMap; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; /** * Represents a config file. - * - * @author Peter Güttinger */ public class Config implements Comparable { - - boolean simple; - + /** * One level of the indentation, e.g. a tab or 4 spaces. */ private String indentation = "\t"; + /** * The indentation's name, i.e. 'tab' or 'space'. */ private String indentationName = "tab"; - + + private final SectionNode main; + final String defaultSeparator; String separator; - + boolean simple; int level = 0; - - private final SectionNode main; - int errors = 0; - final boolean allowEmptySections; - + String fileName; - @Nullable - Path file = null; - - public Config(final InputStream source, final String fileName, @Nullable final File file, final boolean simple, final boolean allowEmptySections, final String defaultSeparator) throws IOException { - try { + @Nullable Path file = null; + + public Config(InputStream source, String fileName, @Nullable File file, + boolean simple, boolean allowEmptySections, String defaultSeparator) throws IOException { + try (source) { this.fileName = fileName; if (file != null) // Must check for null before converting to path this.file = file.toPath(); @@ -79,236 +60,323 @@ public Config(final InputStream source, final String fileName, @Nullable final F this.allowEmptySections = allowEmptySections; this.defaultSeparator = defaultSeparator; separator = defaultSeparator; - + if (source.available() == 0) { main = new SectionNode(this); Skript.warning("'" + getFileName() + "' is empty"); return; } - + if (Skript.logVeryHigh()) Skript.info("loading '" + fileName + "'"); - + try (ConfigReader reader = new ConfigReader(source)) { main = SectionNode.load(this, reader); } - } finally { - source.close(); } } - - public Config(final InputStream source, final String fileName, final boolean simple, final boolean allowEmptySections, final String defaultSeparator) throws IOException { + + public Config(InputStream source, String fileName, boolean simple, + boolean allowEmptySections, String defaultSeparator) throws IOException { this(source, fileName, null, simple, allowEmptySections, defaultSeparator); } - - public Config(final File file, final boolean simple, final boolean allowEmptySections, final String defaultSeparator) throws IOException { + + public Config(File file, boolean simple, + boolean allowEmptySections, String defaultSeparator) throws IOException { this(Files.newInputStream(file.toPath()), file.getName(), simple, allowEmptySections, defaultSeparator); this.file = file.toPath(); } - - @SuppressWarnings("null") - public Config(final Path file, final boolean simple, final boolean allowEmptySections, final String defaultSeparator) throws IOException { + + public Config(@NotNull Path file, boolean simple, + boolean allowEmptySections, String defaultSeparator) throws IOException { this(Channels.newInputStream(FileChannel.open(file)), "" + file.getFileName(), simple, allowEmptySections, defaultSeparator); this.file = file; } - + /** - * For testing - * - * @param s - * @param fileName - * @param simple - * @param allowEmptySections - * @param defaultSeparator - * @throws IOException + * Sets all {@link Option} fields of the given object to the values from this config */ - public Config(final String s, final String fileName, final boolean simple, final boolean allowEmptySections, final String defaultSeparator) throws IOException { - this(new ByteArrayInputStream(s.getBytes(ConfigReader.UTF_8)), fileName, simple, allowEmptySections, defaultSeparator); + public void load(Object object) { + load(object.getClass(), object, ""); } - void setIndentation(final String indent) { - assert indent != null && !indent.isEmpty() : indent; - indentation = indent; - indentationName = (indent.charAt(0) == ' ' ? "space" : "tab"); - } - - String getIndentation() { - return indentation; - } - - String getIndentationName() { - return indentationName; + /** + * Sets all static {@link Option} fields of the given class to the values from this config + */ + public void load(Class clazz) { + load(clazz, null, ""); } - - public SectionNode getMainNode() { - return main; + + private void load(Class clazz, @Nullable Object object, String path) { + for (Field field : clazz.getDeclaredFields()) { + field.setAccessible(true); + if (object != null || Modifier.isStatic(field.getModifiers())) { + try { + if (OptionSection.class.isAssignableFrom(field.getType())) { + OptionSection section = (OptionSection) field.get(object); + @NotNull Class pc = section.getClass(); + load(pc, section, path + section.key + "."); + } else if (Option.class.isAssignableFrom(field.getType())) { + ((Option) field.get(object)).set(this, path); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + assert false; + } + } + } } - - public String getFileName() { - return fileName; + + void setIndentation(String indent) { + assert indent != null && !indent.isEmpty() : indent; + indentation = indent; + indentationName = indent.charAt(0) == ' ' ? "space" : "tab"; } - + /** * Saves the config to a file. * - * @param f The file to save to + * @param file The file to save to * @throws IOException If the file could not be written to. */ - public void save(final File f) throws IOException { + public void save(File file) throws IOException { separator = defaultSeparator; - final PrintWriter w = new PrintWriter(f, "UTF-8"); + PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8); try { - main.save(w); + main.save(writer); } finally { - w.flush(); - w.close(); + writer.flush(); + writer.close(); } } - + /** - * Sets this config's values to those in the given config. - *

- * Used by Skript to import old settings into the updated config. The return value is used to not modify the config if no new options were added. - * - * @param other - * @return Whether the configs' keys differ, i.e. false == configs only differ in values, not keys. + * @deprecated This copies all values from the other config and sets them in this config, + * which could be destructive for sensitive data if something goes wrong. + * Also removes user comments. + * Use {@link #updateNodes(Config)} instead. */ + @Deprecated(forRemoval = true) public boolean setValues(final Config other) { return getMainNode().setValues(other.getMainNode()); } - + + /** + * @deprecated This copies all values from the other config and sets them in this config, + * which could be destructive for sensitive data if something goes wrong. + * Also removes user comments. + * Use {@link #updateNodes(Config)} instead. + */ + @Deprecated(forRemoval = true) public boolean setValues(final Config other, final String... excluded) { return getMainNode().setValues(other.getMainNode(), excluded); } /** - * Compares the keys and values of this Config and another. - * @param other The other Config. - * @param excluded Keys to exclude from this comparison. - * @return True if there are differences in the keys and their values - * of this Config and the other Config. + * Updates the nodes of this config with the nodes of another config. + * Used for updating a config file to a newer version. + *

+ * This method only sets nodes that are missing in this config, thus preserving any existing values. + *

+ * + * @param newer The newer config to update from. + * @return True if any keys were added to this config, false otherwise. */ - public boolean compareValues(Config other, String... excluded) { - return getMainNode().compareValues(other.getMainNode(), excluded); - } - - @Nullable - public File getFile() { - if (file != null) { - try { - return file.toFile(); - } catch (Exception e) { - return null; // ZipPath, for example, throws undocumented exception + public boolean updateNodes(@NotNull Config newer) { + Skript.debug("Updating config %s", newer.getFileName()); + Set newNodes = discoverNodes(newer.getMainNode()); + Set oldNodes = discoverNodes(getMainNode()); + + newNodes.removeAll(oldNodes); + Set nodesToUpdate = new LinkedHashSet<>(newNodes); + + if (nodesToUpdate.isEmpty()) + return false; + + for (Node node : nodesToUpdate) { + Skript.debug("Updating node %s", node); + SectionNode newParent = node.getParent(); + Preconditions.checkNotNull(newParent); + + SectionNode parent = getNode(newParent.getPath()); + Preconditions.checkNotNull(parent); + + int index = node.getIndex(); + if (index >= parent.size()) { + Skript.debug("Adding node %s to %s (size mismatch)", node, parent); + parent.add(node); + continue; + } + + Node existing = parent.getAt(index); + if (existing != null) { // insert between existing + Skript.debug("Adding node %s to %s at index %s", node, parent, index); + parent.add(index, node); + } else { + Skript.debug("Adding node %s to %s", node, parent); + parent.add(node); } } - return null; + return true; } - - @Nullable - public Path getPath() { - return file; + + /** + * Recursively finds all nodes in a section node, including other + * section nodes, entry nodes, and void nodes. + * + * @param node The parent node to search. + * @return A set of the discovered nodes, guaranteed to be in the order of discovery. + */ + @Contract(pure = true) + static @NotNull Set discoverNodes(@NotNull SectionNode node) { + Set nodes = new LinkedHashSet<>(); + + for (Iterator iterator = node.fullIterator(); iterator.hasNext(); ) { + Node child = iterator.next(); + if (child instanceof SectionNode sectionChild) { + nodes.add(child); + nodes.addAll(discoverNodes(sectionChild)); + } else if (child instanceof EntryNode || child instanceof VoidNode) { + nodes.add(child); + } + } + return nodes; } - + /** - * @return The most recent separator. Only useful while the file is loading. + * Returns the {@link SectionNode} at the given path from the root, + * where {@code path} is an array of keys to traverse. + * + * @param path The path to the node. + * @return The {@link SectionNode} at the given path. */ - public String getSeparator() { - return separator; + private SectionNode getNode(String... path) { + SectionNode node = getMainNode(); + for (String key : path) { + Node child = node.get(key); + + if (child instanceof SectionNode sectionNode) { + node = sectionNode; + } else { + return node; + } + } + return node; } - + /** - * @return A separator string useful for saving, e.g. ": " or " = ". + * Compares the keys and values of this Config and another. + * + * @param other The other Config. + * @param excluded Keys to exclude from this comparison. + * @return True if there are differences in the keys and their values + * of this Config and the other Config. */ - public String getSaveSeparator() { - if (separator.equals(":")) - return ": "; - if (separator.equals("=")) - return " = "; - return " " + separator + " "; + public boolean compareValues(Config other, String... excluded) { + return getMainNode().compareValues(other.getMainNode(), excluded); } - + /** * Splits the given path at the dot character and passes the result to {@link #get(String...)}. * * @param path * @return get(path.split("\\.")) */ - @SuppressWarnings("null") - @Nullable - public String getByPath(final String path) { + public @Nullable String getByPath(@NotNull String path) { return get(path.split("\\.")); } - + /** * Gets an entry node's value at the designated path * * @param path * @return The entry node's value at the location defined by path or null if it either doesn't exist or is not an entry. */ - @Nullable - public String get(final String... path) { + public @Nullable String get(String... path) { SectionNode section = main; for (int i = 0; i < path.length; i++) { - final Node n = section.get(path[i]); - if (n == null) + Node node = section.get(path[i]); + if (node == null) return null; - if (n instanceof SectionNode) { + if (node instanceof SectionNode sectionNode) { if (i == path.length - 1) return null; - section = (SectionNode) n; + section = sectionNode; } else { - if (n instanceof EntryNode && i == path.length - 1) - return ((EntryNode) n).getValue(); + if (node instanceof EntryNode entryNode && i == path.length - 1) + return entryNode.getValue(); else return null; } } return null; } - - public boolean isEmpty() { - return main.isEmpty(); - } - - public HashMap toMap(final String separator) { + + public Map toMap(String separator) { return main.toMap("", separator); } - - public boolean validate(final SectionValidator validator) { + + public boolean validate(SectionValidator validator) { return validator.validate(getMainNode()); } - - private void load(final Class cls, final @Nullable Object object, final String path) { - for (final Field field : cls.getDeclaredFields()) { - field.setAccessible(true); - if (object != null || Modifier.isStatic(field.getModifiers())) { - try { - if (OptionSection.class.isAssignableFrom(field.getType())) { - final OptionSection section = (OptionSection) field.get(object); - @NotNull final Class pc = section.getClass(); - load(pc, section, path + section.key + "."); - } else if (Option.class.isAssignableFrom(field.getType())) { - ((Option) field.get(object)).set(this, path); - } - } catch (final IllegalArgumentException | IllegalAccessException e) { - assert false; - } - } + + /** + * @return Whether the config is empty. + */ + public boolean isEmpty() { + return main.isEmpty(); + } + + /** + * @return The file this config was loaded from, or null if it was loaded from an InputStream. + */ + public @Nullable File getFile() { + if (file == null) + return null; + + try { + return file.toFile(); + } catch (Exception e) { + return null; // ZipPath, for example, throws undocumented exception } } - + /** - * Sets all {@link Option} fields of the given object to the values from this config + * @return The path this config was loaded from, or null if it was loaded from an InputStream. */ - public void load(final Object o) { - load(o.getClass(), o, ""); + public @Nullable Path getPath() { + return file; } - + /** - * Sets all static {@link Option} fields of the given class to the values from this config + * @return The most recent separator. Only useful while the file is loading. */ - public void load(final Class c) { - load(c, null, ""); + public String getSeparator() { + return separator; + } + + /** + * @return A separator string useful for saving, e.g. ": ". + */ + public String getSaveSeparator() { + if (separator.equals(":")) + return ": "; + return " " + separator + " "; + } + + @NotNull String getIndentation() { + return indentation; + } + + @NotNull String getIndentationName() { + return indentationName; + } + + public @NotNull SectionNode getMainNode() { + return main; + } + + public @NotNull String getFileName() { + return fileName; } @Override @@ -317,5 +385,5 @@ public int compareTo(@Nullable Config other) { return 0; return fileName.compareTo(other.fileName); } - + } diff --git a/src/main/java/ch/njol/skript/config/ConfigReader.java b/src/main/java/ch/njol/skript/config/ConfigReader.java index 8891efd3d6b..c81e755d6b5 100644 --- a/src/main/java/ch/njol/skript/config/ConfigReader.java +++ b/src/main/java/ch/njol/skript/config/ConfigReader.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import java.io.BufferedReader; diff --git a/src/main/java/ch/njol/skript/config/EntryNode.java b/src/main/java/ch/njol/skript/config/EntryNode.java index 93a84ffa5a0..9eddb3653bf 100644 --- a/src/main/java/ch/njol/skript/config/EntryNode.java +++ b/src/main/java/ch/njol/skript/config/EntryNode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import java.util.Map.Entry; @@ -26,30 +8,30 @@ * @author Peter Güttinger */ public class EntryNode extends Node implements Entry { - + private String value; - + public EntryNode(final String key, final String value, final String comment, final SectionNode parent, final int lineNum) { super(key, comment, parent, lineNum); this.value = value; } - + public EntryNode(final String key, final String value, final SectionNode parent) { super(key, parent); this.value = value; } - + @SuppressWarnings("null") @Override public String getKey() { return key; } - + @Override public String getValue() { return value; } - + @Override public String setValue(final @Nullable String v) { if (v == null) @@ -58,10 +40,10 @@ public String setValue(final @Nullable String v) { value = v; return r; } - + @Override String save_i() { return key + config.getSaveSeparator() + value; } - + } diff --git a/src/main/java/ch/njol/skript/config/EnumParser.java b/src/main/java/ch/njol/skript/config/EnumParser.java index 132c7284c0a..3e40e2e0d1b 100644 --- a/src/main/java/ch/njol/skript/config/EnumParser.java +++ b/src/main/java/ch/njol/skript/config/EnumParser.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import java.util.Locale; diff --git a/src/main/java/ch/njol/skript/config/InvalidNode.java b/src/main/java/ch/njol/skript/config/InvalidNode.java index 20922c9413f..b858417bfe6 100644 --- a/src/main/java/ch/njol/skript/config/InvalidNode.java +++ b/src/main/java/ch/njol/skript/config/InvalidNode.java @@ -1,38 +1,20 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; /** * A line of a config that could not be parsed. - * + * * @author Peter Güttinger */ public class InvalidNode extends VoidNode { - + // public InvalidNode(final SectionNode parent, final ConfigReader r) { // super(parent, r); // config.errors++; // } - + public InvalidNode(final String value, final String comment, final SectionNode parent, final int lineNum) { super(value, comment, parent, lineNum); config.errors++; } - + } diff --git a/src/main/java/ch/njol/skript/config/Node.java b/src/main/java/ch/njol/skript/config/Node.java index 65504aa5526..45d1ba69356 100644 --- a/src/main/java/ch/njol/skript/config/Node.java +++ b/src/main/java/ch/njol/skript/config/Node.java @@ -1,61 +1,41 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; -import java.io.PrintWriter; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import ch.njol.skript.SkriptConfig; -import org.jetbrains.annotations.Nullable; - import ch.njol.skript.Skript; import ch.njol.skript.log.SkriptLogger; import ch.njol.util.NonNullPair; import ch.njol.util.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.PrintWriter; +import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; /** * @author Peter Güttinger */ public abstract class Node { - + @Nullable protected String key; - + protected String comment = ""; - + protected final int lineNum; - + private final boolean debug; - + @Nullable protected SectionNode parent; protected Config config; - + // protected Node() { // key = null; // debug = false; // lineNum = -1; // SkriptLogger.setNode(this); // } - + protected Node(final Config c) { key = null; debug = false; @@ -63,7 +43,7 @@ protected Node(final Config c) { config = c; SkriptLogger.setNode(this); } - + protected Node(final String key, final SectionNode parent) { this.key = key; debug = false; @@ -72,7 +52,7 @@ protected Node(final String key, final SectionNode parent) { config = parent.getConfig(); SkriptLogger.setNode(this); } - + protected Node(final String key, final String comment, final SectionNode parent, final int lineNum) { this.key = key; this.comment = comment; @@ -82,7 +62,7 @@ protected Node(final String key, final String comment, final SectionNode parent, config = parent.getConfig(); SkriptLogger.setNode(this); } - + // protected Node(final String key, final SectionNode parent, final ConfigReader r) { // this(key, parent, r.getLine(), r.getLineNum()); // } @@ -94,11 +74,11 @@ protected Node(final String key, final String comment, final SectionNode parent, public String getKey() { return key; } - + public final Config getConfig() { return config; } - + public void rename(final String newname) { if (key == null) throw new IllegalStateException("can't rename an anonymous node"); @@ -107,7 +87,7 @@ public void rename(final String newname) { if (parent != null) parent.renamed(this, oldKey); } - + public void move(final SectionNode newParent) { final SectionNode p = parent; if (p == null) @@ -134,7 +114,7 @@ public static NonNullPair splitLine(String line) { *

* Whitespace is preserved (whitespace in front of the comment is added to the value), and any ## not in quoted strings in the value are replaced by a single #. The comment is returned with a * leading #, except if there is no comment in which case it will be the empty string. - * + * * @param line the line to split * @param inBlockComment Whether we are currently inside a block comment * @return A pair (value, comment). @@ -238,39 +218,39 @@ private static SplitLineState update(char c, SplitLineState state, SplitLineStat return state; } } - + static void handleNodeStackOverflow(StackOverflowError e, String line) { Node n = SkriptLogger.getNode(); SkriptLogger.setNode(null); // Avoid duplicating the which node error occurred in parentheses on every error message - + Skript.error("There was a StackOverFlowError occurred when loading a node. This maybe from your scripts, aliases or Skript configuration."); Skript.error("Please make your script lines shorter! Do NOT report this to SkriptLang unless it occurs with a short script line or built-in aliases!"); - + Skript.error(""); Skript.error("Updating your Java and/or using respective 64-bit versions for your operating system may also help and is always a good practice."); Skript.error("If it is still not fixed, try moderately increasing the thread stack size (-Xss flag) in your startup script."); Skript.error(""); Skript.error("Using a different Java Virtual Machine (JVM) like OpenJ9 or GraalVM may also help; though be aware that not all plugins may support them."); Skript.error(""); - + Skript.error("Line that caused the issue:"); - + // Print the line caused the issue for diagnosing (will be very long most probably), in case of someone pasting this in an issue and not providing the code. Skript.error(line); - + // If testing (assertions enabled) - print the whole stack trace. if (Skript.testing()) { Skript.exception(e); } - + SkriptLogger.setNode(n); // Revert the node back } - + @Nullable protected String getComment() { return comment; } - + int getLevel() { int l = 0; Node n = this; @@ -279,20 +259,20 @@ int getLevel() { } return Math.max(0, l - 1); } - + protected String getIndentation() { return StringUtils.multiply(config.getIndentation(), getLevel()); } - + /** * @return String to save this node as. The correct indentation and the comment will be added automatically, as well as all '#'s will be escaped. */ abstract String save_i(); - + public final String save() { return getIndentation() + escapeUnquotedHashtags(save_i()) + comment; } - + public void save(final PrintWriter w) { w.println(save()); } @@ -327,12 +307,12 @@ private static String escapeUnquotedHashtags(String input) { return output.toString(); } - + @Nullable public SectionNode getParent() { return parent; } - + /** * Removes this node from its parent. Does nothing if this node does not have a parent node. */ @@ -342,21 +322,21 @@ public void remove() { return; p.remove(this); } - + /** * @return Original line of this node at the time it was loaded. -1 if this node was created dynamically. */ public int getLine() { return lineNum; } - + /** * @return Whether this node does not hold information (i.e. is empty or invalid) */ public boolean isVoid() { return this instanceof VoidNode;// || this instanceof ParseOptionNode; } - + // /** // * get a node via path:to:the:node. relative paths are possible by starting with a ':'; a double colon '::' will go up a node.
// * selecting the n-th node can be done with #n. @@ -409,7 +389,7 @@ public boolean isVoid() { // } // return n; // } - + /** * returns information about this node which looks like the following:
* node value #including comments (config.sk, line xyz) @@ -422,9 +402,77 @@ public String toString() { + (comment.isEmpty() ? "" : " " + comment) + " (" + config.getFileName() + ", " + (lineNum == -1 ? "unknown line" : "line " + lineNum) + ")"; } - + public boolean debug() { return debug; } - + + /** + * @return The index of this node relative to the other children of this node's parent, + * or -1 if this node does not have a parent. The index includes counted void nodes. + */ + int getIndex() { + if (parent == null) + return -1; + + int index = 0; + for (Iterator iterator = parent.fullIterator(); iterator.hasNext(); ) { + Node node = iterator.next(); + if (node == this) + return index; + + index++; + } + return -1; + } + + /** + * Returns the path to this node in the config file from the root. + * + *

+ * Getting the path of node {@code z} in the following example would + * return an array with {@code w.x, y, z}. + *

+	 *     w.x:
+	 *      y:
+	 *       z: true # this node
+	 * 

+ * + * @return The path to this node in the config file. + */ + public @NotNull String[] getPath() { + List path = new ArrayList<>(); + Node node = this; + + while (node != null) { + if (node.getKey() == null || node.getKey().isEmpty()) + break; + + path.add(0, node.getKey() + "."); + node = node.getParent(); + } + + if (path.isEmpty()) + return new String[0]; + + int lastIndex = path.size() - 1; + String lastValue = path.get(lastIndex); + path.set(lastIndex, lastValue.substring(0, lastValue.length() - 1)); // trim trailing dot + return path.toArray(new String[0]); + } + + @Override + public boolean equals(Object object) { + if (!(object instanceof Node other)) + return false; + + return Arrays.equals(getPath(), other.getPath()) // for entry/section nodes + && Objects.equals(comment, other.comment); // for void nodes + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(getPath()), comment); + } + } diff --git a/src/main/java/ch/njol/skript/config/NodeMap.java b/src/main/java/ch/njol/skript/config/NodeMap.java index aa45b1490c8..43d0bba521e 100644 --- a/src/main/java/ch/njol/skript/config/NodeMap.java +++ b/src/main/java/ch/njol/skript/config/NodeMap.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import java.util.HashMap; diff --git a/src/main/java/ch/njol/skript/config/OptionSection.java b/src/main/java/ch/njol/skript/config/OptionSection.java index 7d87ff7a10d..be2417d81f1 100644 --- a/src/main/java/ch/njol/skript/config/OptionSection.java +++ b/src/main/java/ch/njol/skript/config/OptionSection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import java.lang.reflect.Field; diff --git a/src/main/java/ch/njol/skript/config/SectionNode.java b/src/main/java/ch/njol/skript/config/SectionNode.java index 8ccc97be625..c280851570c 100644 --- a/src/main/java/ch/njol/skript/config/SectionNode.java +++ b/src/main/java/ch/njol/skript/config/SectionNode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; import ch.njol.skript.Skript; @@ -24,17 +6,15 @@ import ch.njol.skript.config.validate.SectionValidator; import ch.njol.skript.log.SkriptLogger; import ch.njol.util.NonNullPair; -import ch.njol.util.NullableChecker; import ch.njol.util.coll.CollectionUtils; import ch.njol.util.coll.iterator.CheckedIterator; +import com.google.common.base.Preconditions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; @@ -42,23 +22,23 @@ * @author Peter Güttinger */ public class SectionNode extends Node implements Iterable { - + private final ArrayList nodes = new ArrayList<>(); - + public SectionNode(final String key, final String comment, final SectionNode parent, final int lineNum) { super(key, comment, parent, lineNum); } - + SectionNode(final Config c) { super(c); } - + /** * Note to self: use getNodeMap() */ @Nullable private NodeMap nodeMap = null; - + private NodeMap getNodeMap() { NodeMap nodeMap = this.nodeMap; if (nodeMap == null) { @@ -70,17 +50,17 @@ private NodeMap getNodeMap() { } return nodeMap; } - + /** * @return Total amount of nodes (including void nodes) in this section. */ public int size() { return nodes.size(); } - + /** * Adds the given node at the end of this section. - * + * * @param n */ public void add(final Node n) { @@ -90,23 +70,33 @@ public void add(final Node n) { n.config = config; getNodeMap().put(n); } - + /** - * Inserts the given node into this section at the specified position. - * - * @param n - * @param index between 0 and {@link #size()}, inclusive + * Inserts {@code node} into this section at the specified position. + * + * @param node The node to insert + * @param index The index, between 0 and {@link #size()} (inclusive), at which to insert the node */ - public void insert(final Node n, final int index) { - nodes.add(index, n); - n.parent = this; - n.config = config; - getNodeMap().put(n); + public void add(int index, @NotNull Node node) { + Preconditions.checkArgument(index >= 0 && index <= size(), "index out of bounds: %s", index); + + nodes.add(index, node); + node.parent = this; + node.config = config; + getNodeMap().put(node); } - + + /** + * @deprecated Use {@link #add(int, Node)} instead. + */ + @Deprecated(forRemoval = true) + public void insert(Node node, int index) { + add(index, node); + } + /** * Removes the given node from this section. - * + * * @param n */ public void remove(final Node n) { @@ -114,10 +104,10 @@ public void remove(final Node n) { n.parent = null; getNodeMap().remove(n); } - + /** * Removes an entry with the given key. - * + * * @param key * @return The removed node, or null if the key didn't match any node. */ @@ -130,47 +120,59 @@ public Node remove(final String key) { n.parent = null; return n; } - + + /** + * Gets the node at the specified index. May be null. + * The index includes all nodes, including void nodes. + * + * @param index The index of the node to get + * @return The node at the specified index. May be null. + * @throws IllegalArgumentException if the index is out of bounds + */ + @Nullable Node getAt(int index) { + Preconditions.checkArgument(index >= 0 && index < size(), "index out of bounds: %s", index); + return nodes.get(index); + } + /** - * Iterator over all non-void nodes of this section. + * @return An iterator over all non-void nodes in this section. */ @Override - public Iterator iterator() { - @SuppressWarnings("null") - @NotNull - final Iterator iter = nodes.iterator(); - return new CheckedIterator(iter, new NullableChecker() { - @Override - public boolean check(final @Nullable Node n) { - return n != null && !n.isVoid(); - } - }) { + public @NotNull Iterator iterator() { + //noinspection ConstantConditions - Null check is present in fullIterator() + return new CheckedIterator<>(fullIterator(), n -> !n.isVoid()); + } + + /** + * @return An iterator over all nodes in this section, including void nodes. + */ + public @NotNull Iterator fullIterator() { + return new CheckedIterator<>(nodes.iterator(), Objects::nonNull) { @Override public boolean hasNext() { - final boolean hasNext = super.hasNext(); + boolean hasNext = super.hasNext(); if (!hasNext) SkriptLogger.setNode(SectionNode.this); return hasNext; } - + @Override - @Nullable - public Node next() { - final Node n = super.next(); - SkriptLogger.setNode(n); - return n; + public @Nullable Node next() { + Node node = super.next(); + SkriptLogger.setNode(node); + return node; } - + @Override public void remove() { throw new UnsupportedOperationException(); } }; } - + /** * Gets a subnode (EntryNode or SectionNode) with the specified name. - * + * * @param key * @return The node with the given name */ @@ -178,7 +180,7 @@ public void remove() { public Node get(final @Nullable String key) { return getNodeMap().get(key); } - + @Nullable public String getValue(final String key) { final Node n = get(key); @@ -186,10 +188,10 @@ public String getValue(final String key) { return ((EntryNode) n).getValue(); return null; } - + /** * Gets an entry's value or the default value if it doesn't exist or is not an EntryNode. - * + * * @param name The name of the node (case insensitive) * @param def The default value * @return The value of the entry node with the give node, or def if there's no entry with the given name. @@ -200,7 +202,7 @@ public String get(final String name, final String def) { return def; return ((EntryNode) n).getValue(); } - + public void set(final String key, final String value) { final Node n = get(key); if (n instanceof EntryNode) { @@ -209,7 +211,7 @@ public void set(final String key, final String value) { add(new EntryNode(key, value, this)); } } - + public void set(final String key, final @Nullable Node node) { if (node == null) { remove(key); @@ -231,14 +233,14 @@ public void set(final String key, final @Nullable Node node) { } add(node); } - + void renamed(final Node node, final @Nullable String oldKey) { if (!nodes.contains(node)) throw new IllegalArgumentException(); getNodeMap().remove(oldKey); getNodeMap().put(node); } - + public boolean isEmpty() { for (final Node node : nodes) { if (!node.isVoid()) @@ -246,11 +248,11 @@ public boolean isEmpty() { } return true; } - + static SectionNode load(final Config c, final ConfigReader r) throws IOException { return new SectionNode(c).load_i(r); } - + static SectionNode load(final String name, final String comment, final SectionNode parent, final ConfigReader r) throws IOException { parent.config.level++; final SectionNode node = new SectionNode(name, comment, parent, r.getLineNum()).load_i(r); @@ -258,7 +260,7 @@ static SectionNode load(final String name, final String comment, final SectionNo parent.config.level--; return node; } - + private static String readableWhitespace(final String s) { if (s.matches(" +")) return s.length() + " space" + (s.length() == 1 ? "" : "s"); @@ -266,9 +268,9 @@ private static String readableWhitespace(final String s) { return s.length() + " tab" + (s.length() == 1 ? "" : "s"); return "'" + s.replace("\t", "->").replace(' ', '_').replaceAll("\\s", "?") + "' [-> = tab, _ = space, ? = other whitespace]"; } - + private static final Pattern fullLinePattern = Pattern.compile("([^#]|##)*#-#(\\s.*)?"); - + private SectionNode load_i(final ConfigReader r) throws IOException { boolean indentationSet = false; String fullLine; @@ -282,7 +284,7 @@ private SectionNode load_i(final ConfigReader r) throws IOException { final NonNullPair line = Node.splitLine(fullLine, inBlockComment); String value = line.getFirst(); final String comment = line.getSecond(); - + final SectionNode parent = this.parent; if (!indentationSet && parent != null && parent.parent == null && !value.isEmpty() && !value.matches("\\s*") && !value.matches("\\S.*")) { final String s = value.replaceFirst("\\S.*$", ""); @@ -305,20 +307,20 @@ private SectionNode load_i(final ConfigReader r) throws IOException { } else { if (parent != null && !config.allowEmptySections && isEmpty()) { Skript.warning("Empty configuration section! You might want to indent one or more of the subsequent lines to make them belong to this section" + - " or remove the colon at the end of the line if you don't want this line to start a section."); + " or remove the colon at the end of the line if you don't want this line to start a section."); } r.reset(); return this; } } - + value = value.trim(); - - if (value.isEmpty()) { + + if (value.isEmpty()) { // entire line is a comment or empty nodes.add(new VoidNode(value, comment, this, r.getLineNum())); continue; } - + // if (line.startsWith("!") && line.indexOf('[') != -1 && line.endsWith("]")) { // final String option = line.substring(1, line.indexOf('[')); // final String value = line.substring(line.indexOf('[') + 1, line.length() - 1); @@ -342,11 +344,11 @@ private SectionNode load_i(final ConfigReader r) throws IOException { // nodes.add(new ParseOptionNode(line.substring(0, line.indexOf('[')), this, r)); // continue; // } - + if (value.endsWith(":") && (config.simple - || value.indexOf(config.separator) == -1 - || config.separator.endsWith(":") && value.indexOf(config.separator) == value.length() - config.separator.length() - )) { + || value.indexOf(config.separator) == -1 + || config.separator.endsWith(":") && value.indexOf(config.separator) == value.length() - config.separator.length() + )) { boolean matches = false; try { matches = fullLine.contains("#") && fullLinePattern.matcher(fullLine).matches(); @@ -358,22 +360,22 @@ private SectionNode load_i(final ConfigReader r) throws IOException { continue; } } - + if (config.simple) { nodes.add(new SimpleNode(value, comment, r.getLineNum(), this)); } else { nodes.add(getEntry(value, comment, r.getLineNum(), config.separator)); } - + } if (inBlockComment.get()) { Skript.error("A block comment (###) was opened on line " + blockCommentStartLine + " but never closed."); } SkriptLogger.setNode(parent); - + return this; } - + private Node getEntry(final String keyAndValue, final String comment, final int lineNum, final String separator) { final int x = keyAndValue.indexOf(separator); if (x == -1) { @@ -386,19 +388,19 @@ private Node getEntry(final String keyAndValue, final String comment, final int final String value = "" + keyAndValue.substring(x + separator.length()).trim(); return new EntryNode(key, value, comment, this, lineNum); } - + /** * Converts all SimpleNodes in this section to EntryNodes. - * + * * @param levels Amount of levels to go down, e.g. 0 to only convert direct subnodes of this section or -1 for all subnodes including subnodes of subnodes etc. */ public void convertToEntries(final int levels) { convertToEntries(levels, config.separator); } - + /** * REMIND breaks saving - separator argument can be different from config.sepator - * + * * @param levels Maximum depth of recursion, -1 for no limit. * @param separator Some separator, e.g. ":" or "=". */ @@ -421,7 +423,7 @@ public void convertToEntries(final int levels, final String separator) { assert false; } } - + @Override public void save(final PrintWriter w) { if (parent != null) @@ -429,19 +431,19 @@ public void save(final PrintWriter w) { for (final Node node : nodes) node.save(w); } - + @Override String save_i() { assert key != null; return key + ":"; } - + public boolean validate(final SectionValidator validator) { return validator.validate(this); } - - HashMap toMap(final String prefix, final String separator) { - final HashMap r = new HashMap<>(); + + Map toMap(final String prefix, final String separator) { + final Map r = new HashMap<>(); for (final Node n : this) { if (n instanceof EntryNode) { r.put(prefix + n.getKey(), ((EntryNode) n).getValue()); @@ -452,6 +454,18 @@ HashMap toMap(final String prefix, final String separator) { return r; } + /** + * @return True if this section and all children are valid, i.e. they contain no invalid nodes. + */ + public boolean isValid() { + for (Node node : nodes) { + if ((node instanceof SectionNode sectionNode && !sectionNode.isValid()) + || node instanceof InvalidNode) + return false; + } + return true; + } + /** * Updates the values of this SectionNode based on the values of another SectionNode. * @param other The other SectionNode. @@ -526,5 +540,5 @@ private boolean modify(SectionNode other, boolean compareValues, String... exclu return different; } - + } diff --git a/src/main/java/ch/njol/skript/config/SimpleNode.java b/src/main/java/ch/njol/skript/config/SimpleNode.java index 3da391c0d5e..33a4a215ec2 100644 --- a/src/main/java/ch/njol/skript/config/SimpleNode.java +++ b/src/main/java/ch/njol/skript/config/SimpleNode.java @@ -1,44 +1,26 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; /** * @author Peter Güttinger */ public class SimpleNode extends Node { - + public SimpleNode(final String value, final String comment, final int lineNum, final SectionNode parent) { super(value, comment, parent, lineNum); } - + public SimpleNode(final Config c) { super(c); } - + @SuppressWarnings("null") @Override String save_i() { return key; } - + public void set(final String s) { key = s; } - + } diff --git a/src/main/java/ch/njol/skript/config/VoidNode.java b/src/main/java/ch/njol/skript/config/VoidNode.java index c94f4512175..cc93d4af082 100644 --- a/src/main/java/ch/njol/skript/config/VoidNode.java +++ b/src/main/java/ch/njol/skript/config/VoidNode.java @@ -1,51 +1,33 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config; /** * An empty line or a comment. *

* The subclass {@link InvalidNode} is used for invalid non-empty nodes, i.e. where a parsing error occurred. - * + * * @author Peter Güttinger */ public class VoidNode extends Node { - + // private final int initialLevel; // private final String initialIndentation; - + VoidNode(final String line, final String comment, final SectionNode parent, final int lineNum) { super("" + line.trim(), comment, parent, lineNum); // initialLevel = getLevel(); // initialIndentation = "" + line.replaceFirst("\\S.*$", ""); } - + @SuppressWarnings("null") @Override public String getKey() { return key; } - + public void set(final String s) { key = s; } - + // doesn't work reliably // @Override // protected String getIndentation() { @@ -62,10 +44,10 @@ public void set(final String s) { // return ind; // } // } - + @Override String save_i() { return "" + key; } - + } diff --git a/src/main/java/ch/njol/skript/config/validate/EntryValidator.java b/src/main/java/ch/njol/skript/config/validate/EntryValidator.java index 16efab55581..05f40feb641 100644 --- a/src/main/java/ch/njol/skript/config/validate/EntryValidator.java +++ b/src/main/java/ch/njol/skript/config/validate/EntryValidator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config.validate; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/config/validate/EnumEntryValidator.java b/src/main/java/ch/njol/skript/config/validate/EnumEntryValidator.java index 274c08be6ea..ccdbf71a612 100644 --- a/src/main/java/ch/njol/skript/config/validate/EnumEntryValidator.java +++ b/src/main/java/ch/njol/skript/config/validate/EnumEntryValidator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config.validate; import java.util.Locale; diff --git a/src/main/java/ch/njol/skript/config/validate/NodeValidator.java b/src/main/java/ch/njol/skript/config/validate/NodeValidator.java index a5dd5b32c2f..1f4b5fc068d 100644 --- a/src/main/java/ch/njol/skript/config/validate/NodeValidator.java +++ b/src/main/java/ch/njol/skript/config/validate/NodeValidator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config.validate; import ch.njol.skript.config.Node; diff --git a/src/main/java/ch/njol/skript/config/validate/ParsedEntryValidator.java b/src/main/java/ch/njol/skript/config/validate/ParsedEntryValidator.java index d949279741a..3f382739fe8 100644 --- a/src/main/java/ch/njol/skript/config/validate/ParsedEntryValidator.java +++ b/src/main/java/ch/njol/skript/config/validate/ParsedEntryValidator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config.validate; import ch.njol.skript.classes.Parser; diff --git a/src/main/java/ch/njol/skript/config/validate/SectionValidator.java b/src/main/java/ch/njol/skript/config/validate/SectionValidator.java index 322c53e5bba..1c5482aa39c 100644 --- a/src/main/java/ch/njol/skript/config/validate/SectionValidator.java +++ b/src/main/java/ch/njol/skript/config/validate/SectionValidator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.config.validate; import java.util.HashMap; diff --git a/src/main/java/ch/njol/skript/doc/Description.java b/src/main/java/ch/njol/skript/doc/Description.java index b5eb0f17ef5..a24b8bad012 100644 --- a/src/main/java/ch/njol/skript/doc/Description.java +++ b/src/main/java/ch/njol/skript/doc/Description.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/Documentation.java b/src/main/java/ch/njol/skript/doc/Documentation.java index 7b5b2ac7044..73b158b1a9d 100644 --- a/src/main/java/ch/njol/skript/doc/Documentation.java +++ b/src/main/java/ch/njol/skript/doc/Documentation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/doc/DocumentationId.java b/src/main/java/ch/njol/skript/doc/DocumentationId.java index e1d1543f2e6..b425e60ee20 100644 --- a/src/main/java/ch/njol/skript/doc/DocumentationId.java +++ b/src/main/java/ch/njol/skript/doc/DocumentationId.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/Events.java b/src/main/java/ch/njol/skript/doc/Events.java index 8982905871e..592cdc1bb82 100644 --- a/src/main/java/ch/njol/skript/doc/Events.java +++ b/src/main/java/ch/njol/skript/doc/Events.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/Examples.java b/src/main/java/ch/njol/skript/doc/Examples.java index 1873ffaabf3..b8946e8ac1c 100644 --- a/src/main/java/ch/njol/skript/doc/Examples.java +++ b/src/main/java/ch/njol/skript/doc/Examples.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/Keywords.java b/src/main/java/ch/njol/skript/doc/Keywords.java index b9c69ccf5bf..1d10575aa75 100644 --- a/src/main/java/ch/njol/skript/doc/Keywords.java +++ b/src/main/java/ch/njol/skript/doc/Keywords.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/Name.java b/src/main/java/ch/njol/skript/doc/Name.java index 162af205ec0..b41aec52ade 100644 --- a/src/main/java/ch/njol/skript/doc/Name.java +++ b/src/main/java/ch/njol/skript/doc/Name.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/NoDoc.java b/src/main/java/ch/njol/skript/doc/NoDoc.java index 7298002e603..8368643012b 100644 --- a/src/main/java/ch/njol/skript/doc/NoDoc.java +++ b/src/main/java/ch/njol/skript/doc/NoDoc.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/RequiredPlugins.java b/src/main/java/ch/njol/skript/doc/RequiredPlugins.java index 911b4fc50f5..074a4e6bfd2 100644 --- a/src/main/java/ch/njol/skript/doc/RequiredPlugins.java +++ b/src/main/java/ch/njol/skript/doc/RequiredPlugins.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/doc/Since.java b/src/main/java/ch/njol/skript/doc/Since.java index fda08173456..b88e2f965b3 100644 --- a/src/main/java/ch/njol/skript/doc/Since.java +++ b/src/main/java/ch/njol/skript/doc/Since.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.doc; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/effects/Delay.java b/src/main/java/ch/njol/skript/effects/Delay.java index 55f19199ef1..72e1a0dd786 100644 --- a/src/main/java/ch/njol/skript/effects/Delay.java +++ b/src/main/java/ch/njol/skript/effects/Delay.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffActionBar.java b/src/main/java/ch/njol/skript/effects/EffActionBar.java index 30f260f5807..07647482d3c 100644 --- a/src/main/java/ch/njol/skript/effects/EffActionBar.java +++ b/src/main/java/ch/njol/skript/effects/EffActionBar.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffApplyBoneMeal.java b/src/main/java/ch/njol/skript/effects/EffApplyBoneMeal.java index a758ebbc5eb..1a1712eedbf 100644 --- a/src/main/java/ch/njol/skript/effects/EffApplyBoneMeal.java +++ b/src/main/java/ch/njol/skript/effects/EffApplyBoneMeal.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffBan.java b/src/main/java/ch/njol/skript/effects/EffBan.java index bbaf1c1d7d7..02fd79af8d2 100644 --- a/src/main/java/ch/njol/skript/effects/EffBan.java +++ b/src/main/java/ch/njol/skript/effects/EffBan.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffBlockUpdate.java b/src/main/java/ch/njol/skript/effects/EffBlockUpdate.java new file mode 100644 index 00000000000..fa19c3b4b8c --- /dev/null +++ b/src/main/java/ch/njol/skript/effects/EffBlockUpdate.java @@ -0,0 +1,67 @@ +package ch.njol.skript.effects; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@Name("Update Block") +@Description({ + "Updates the blocks by setting them to a selected block", + "Using 'without physics' will not send updates to the surrounding blocks of the blocks being set.", + "Example: Updating a block next to a sand block in the air 'without physics' will not cause the sand block to fall." +}) +@Examples({ + "update {_blocks::*} as gravel", + "update {_blocks::*} to be sand without physics updates", + "update {_blocks::*} as stone without neighbouring updates" +}) +@Since("INSERT VERSION") +// Originally sourced from SkBee by ShaneBee (https://github.com/ShaneBeee/SkBee/blob/master/src/main/java/com/shanebeestudios/skbee/elements/other/effects/EffBlockstateUpdate.java) +public class EffBlockUpdate extends Effect { + + static { + Skript.registerEffect(EffBlockUpdate.class, + "update %blocks% (as|to be) %blockdata% [physics:without [neighbo[u]r[ing]|adjacent] [physic[s]] update[s]]"); + } + + private boolean physics; + private Expression blocks; + private Expression blockData; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + this.physics = !parseResult.hasTag("physics"); + this.blocks = (Expression) exprs[0]; + this.blockData = (Expression) exprs[1]; + return true; + } + + @Override + protected void execute(Event event) { + BlockData data = this.blockData.getSingle(event); + if (data == null) + return; + for (Block block : this.blocks.getArray(event)) { + block.setBlockData(data, this.physics); + } + } + + @Override + public @NotNull String toString(@Nullable Event event, boolean debug) { + return "update " + this.blocks.toString(event, debug) + " as " + + this.blockData.toString(event, debug) + (this.physics ? "without neighbour updates" : ""); + } + +} diff --git a/src/main/java/ch/njol/skript/effects/EffBreakNaturally.java b/src/main/java/ch/njol/skript/effects/EffBreakNaturally.java index 384d3d64a6e..2b1cce956dc 100644 --- a/src/main/java/ch/njol/skript/effects/EffBreakNaturally.java +++ b/src/main/java/ch/njol/skript/effects/EffBreakNaturally.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.block.Block; diff --git a/src/main/java/ch/njol/skript/effects/EffBroadcast.java b/src/main/java/ch/njol/skript/effects/EffBroadcast.java index 373565bfe6d..7b41e1f41fd 100644 --- a/src/main/java/ch/njol/skript/effects/EffBroadcast.java +++ b/src/main/java/ch/njol/skript/effects/EffBroadcast.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/effects/EffCancelCooldown.java b/src/main/java/ch/njol/skript/effects/EffCancelCooldown.java index 43330d42acf..a8706029d00 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelCooldown.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelCooldown.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffCancelDrops.java b/src/main/java/ch/njol/skript/effects/EffCancelDrops.java index 65e49689146..685b2d4e046 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelDrops.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelDrops.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffCancelItemUse.java b/src/main/java/ch/njol/skript/effects/EffCancelItemUse.java index e89967e3662..dc3013686fc 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelItemUse.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelItemUse.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffChange.java b/src/main/java/ch/njol/skript/effects/EffChange.java index ee2e2e012be..0a755e24f57 100644 --- a/src/main/java/ch/njol/skript/effects/EffChange.java +++ b/src/main/java/ch/njol/skript/effects/EffChange.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/effects/EffColorItems.java b/src/main/java/ch/njol/skript/effects/EffColorItems.java index 9f8a7ad5657..6f2fc81dce1 100644 --- a/src/main/java/ch/njol/skript/effects/EffColorItems.java +++ b/src/main/java/ch/njol/skript/effects/EffColorItems.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffCommand.java b/src/main/java/ch/njol/skript/effects/EffCommand.java index 4b3c7a36d43..22f16cbe01a 100644 --- a/src/main/java/ch/njol/skript/effects/EffCommand.java +++ b/src/main/java/ch/njol/skript/effects/EffCommand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/effects/EffCopy.java b/src/main/java/ch/njol/skript/effects/EffCopy.java index c333c2d9e26..c792cf8925f 100644 --- a/src/main/java/ch/njol/skript/effects/EffCopy.java +++ b/src/main/java/ch/njol/skript/effects/EffCopy.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffDoIf.java b/src/main/java/ch/njol/skript/effects/EffDoIf.java index 4cc6de996ac..0b0cc219177 100644 --- a/src/main/java/ch/njol/skript/effects/EffDoIf.java +++ b/src/main/java/ch/njol/skript/effects/EffDoIf.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffDrop.java b/src/main/java/ch/njol/skript/effects/EffDrop.java index 0035731a7a1..29fb211b9ad 100644 --- a/src/main/java/ch/njol/skript/effects/EffDrop.java +++ b/src/main/java/ch/njol/skript/effects/EffDrop.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffElytraBoostConsume.java b/src/main/java/ch/njol/skript/effects/EffElytraBoostConsume.java new file mode 100644 index 00000000000..bac6f6a7851 --- /dev/null +++ b/src/main/java/ch/njol/skript/effects/EffElytraBoostConsume.java @@ -0,0 +1,58 @@ +package ch.njol.skript.effects; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.*; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +@Name("Consume Boosting Firework") +@Description("Prevent the firework used in an 'elytra boost' event to be consumed.") +@Examples({ + "on elytra boost:", + "\tif the used firework will be consumed:", + "\t\tprevent the used firework from being consume" +}) +@RequiredPlugins("Paper") +@Since("INSERT VERSION") +public class EffElytraBoostConsume extends Effect { + + static { + if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) { + Skript.registerEffect(EffElytraBoostConsume.class, + "(prevent|disallow) [the] (boosting|used) firework from being consumed", + "allow [the] (boosting|used) firework to be consumed"); + } + } + + private boolean consume; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + if (!getParser().isCurrentEvent(PlayerElytraBoostEvent.class)) { + Skript.error("This effect can only be used in an 'elytra boost' event."); + return false; + } + consume = matchedPattern == 1; + return true; + } + + @Override + protected void execute(Event event) { + if (!(event instanceof PlayerElytraBoostEvent boostEvent)) + return; + boostEvent.setShouldConsume(consume); + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + if (consume) + return "allow the boosting firework to be consumed"; + return "prevent the boosting firework from being consumed"; + } + +} diff --git a/src/main/java/ch/njol/skript/effects/EffEnchant.java b/src/main/java/ch/njol/skript/effects/EffEnchant.java index 0e83dfcfefb..8f41e27c5d0 100644 --- a/src/main/java/ch/njol/skript/effects/EffEnchant.java +++ b/src/main/java/ch/njol/skript/effects/EffEnchant.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffEnforceWhitelist.java b/src/main/java/ch/njol/skript/effects/EffEnforceWhitelist.java index e8bbf9a780c..7b5b2cca22d 100644 --- a/src/main/java/ch/njol/skript/effects/EffEnforceWhitelist.java +++ b/src/main/java/ch/njol/skript/effects/EffEnforceWhitelist.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/effects/EffExceptionDebug.java b/src/main/java/ch/njol/skript/effects/EffExceptionDebug.java index e819190b170..af2f6480ca7 100644 --- a/src/main/java/ch/njol/skript/effects/EffExceptionDebug.java +++ b/src/main/java/ch/njol/skript/effects/EffExceptionDebug.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffExplodeCreeper.java b/src/main/java/ch/njol/skript/effects/EffExplodeCreeper.java index 6ae10a2f4f3..c9937916d14 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplodeCreeper.java +++ b/src/main/java/ch/njol/skript/effects/EffExplodeCreeper.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Creeper; diff --git a/src/main/java/ch/njol/skript/effects/EffExplosion.java b/src/main/java/ch/njol/skript/effects/EffExplosion.java index f2e301559a9..93c413aa47d 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplosion.java +++ b/src/main/java/ch/njol/skript/effects/EffExplosion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/effects/EffFeed.java b/src/main/java/ch/njol/skript/effects/EffFeed.java index 61b2506bda2..4ca51be1bbd 100644 --- a/src/main/java/ch/njol/skript/effects/EffFeed.java +++ b/src/main/java/ch/njol/skript/effects/EffFeed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffFireResistant.java b/src/main/java/ch/njol/skript/effects/EffFireResistant.java index c5044e376fe..26560eb1699 100644 --- a/src/main/java/ch/njol/skript/effects/EffFireResistant.java +++ b/src/main/java/ch/njol/skript/effects/EffFireResistant.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffFireworkLaunch.java b/src/main/java/ch/njol/skript/effects/EffFireworkLaunch.java index 4a7ef269664..1f44850104a 100644 --- a/src/main/java/ch/njol/skript/effects/EffFireworkLaunch.java +++ b/src/main/java/ch/njol/skript/effects/EffFireworkLaunch.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.FireworkEffect; diff --git a/src/main/java/ch/njol/skript/effects/EffForceAttack.java b/src/main/java/ch/njol/skript/effects/EffForceAttack.java index fb885fb6ba5..dc8f19cc02a 100644 --- a/src/main/java/ch/njol/skript/effects/EffForceAttack.java +++ b/src/main/java/ch/njol/skript/effects/EffForceAttack.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffForceEnchantmentGlint.java b/src/main/java/ch/njol/skript/effects/EffForceEnchantmentGlint.java new file mode 100644 index 00000000000..419267a985f --- /dev/null +++ b/src/main/java/ch/njol/skript/effects/EffForceEnchantmentGlint.java @@ -0,0 +1,73 @@ +package ch.njol.skript.effects; + +import org.bukkit.event.Event; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.Nullable; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.doc.*; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; + +@Name("Force Enchantment Glint") +@Description("Forces the items to glint or not, or removes its existing enchantment glint enforcement.") +@Examples({ + "force {_items::*} to glint", + "force the player's tool to stop glinting" +}) +@RequiredPlugins("Spigot 1.20.5+") +@Since("INSERT VERSION") +public class EffForceEnchantmentGlint extends Effect { + + static { + if (Skript.methodExists(ItemMeta.class, "setEnchantmentGlintOverride", Boolean.class)) + Skript.registerEffect(EffForceEnchantmentGlint.class, + "(force|make) %itemtypes% [to] [start] glint[ing]", + "(force|make) %itemtypes% [to] (not|stop) glint[ing]", + "(clear|delete|reset) [the] enchantment glint override of %itemtypes%", + "(clear|delete|reset) %itemtypes%'s enchantment glint override"); + } + + private Expression itemTypes; + private int pattern; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + itemTypes = (Expression) expressions[0]; + pattern = matchedPattern; + return true; + } + + @Override + protected void execute(Event event) { + for (ItemType itemType : itemTypes.getArray(event)) { + ItemMeta meta = itemType.getItemMeta(); + Boolean glint; + if (pattern == 0) { + // Pattern: forced to glint + glint = true; + } else if (pattern == 1) { + // Pattern: forced to not glint + glint = false; + } else { + // Pattern: Clear glint override + glint = null; + } + meta.setEnchantmentGlintOverride(glint); + itemType.setItemMeta(meta); + } + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + // Pattern: Clear glint override + if (pattern > 1) + return "clear the enchantment glint override of " + itemTypes.toString(event, debug); + return "force " + itemTypes.toString(event, debug) + " to " + (pattern == 0 ? "start" : "stop") + " glinting"; + } + +} diff --git a/src/main/java/ch/njol/skript/effects/EffGlowingText.java b/src/main/java/ch/njol/skript/effects/EffGlowingText.java index d3b9fc85c90..8cd0b84da86 100644 --- a/src/main/java/ch/njol/skript/effects/EffGlowingText.java +++ b/src/main/java/ch/njol/skript/effects/EffGlowingText.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffHandedness.java b/src/main/java/ch/njol/skript/effects/EffHandedness.java index 9d0c870e773..b93e6302e61 100644 --- a/src/main/java/ch/njol/skript/effects/EffHandedness.java +++ b/src/main/java/ch/njol/skript/effects/EffHandedness.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffHealth.java b/src/main/java/ch/njol/skript/effects/EffHealth.java index 43d4a4e883e..2b23bc9e91a 100644 --- a/src/main/java/ch/njol/skript/effects/EffHealth.java +++ b/src/main/java/ch/njol/skript/effects/EffHealth.java @@ -1,30 +1,14 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.bukkitutil.DamageUtils; import ch.njol.skript.bukkitutil.HealthUtils; import ch.njol.skript.bukkitutil.ItemUtils; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; @@ -34,42 +18,53 @@ import ch.njol.util.Math2; import org.bukkit.entity.Damageable; import org.bukkit.event.Event; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnknownNullability; @Name("Damage/Heal/Repair") -@Description("Damage/Heal/Repair an entity, or item.") +@Description({ + "Damage, heal, or repair an entity or item.", + "Servers running Spigot 1.20.4+ can optionally choose to specify a fake damage cause." +}) @Examples({ "damage player by 5 hearts", + "damage player by 3 hearts with fake cause fall", "heal the player", "repair tool of player" }) -@Since("1.0") +@Since("1.0, INSERT VERSION (damage cause)") +@RequiredPlugins("Spigot 1.20.4+ (for damage cause)") public class EffHealth extends Effect { + private static final boolean SUPPORTS_DAMAGE_SOURCE = Skript.classExists("org.bukkit.damage.DamageSource"); static { Skript.registerEffect(EffHealth.class, - "damage %livingentities/itemtypes/slots% by %number% [heart[s]] [with fake cause %-damagecause%]", + "damage %livingentities/itemtypes/slots% by %number% [heart[s]] [with [fake] [damage] cause %-damagecause%]", "heal %livingentities% [by %-number% [heart[s]]]", "repair %itemtypes/slots% [by %-number%]"); } private Expression damageables; - @Nullable - private Expression amount; + private @UnknownNullability Expression amount; private boolean isHealing, isRepairing; + private @UnknownNullability Expression exprCause = null; - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - if (matchedPattern == 0 && exprs[2] != null) - Skript.warning("The fake damage cause extension of this effect has no functionality, " + - "and will be removed in the future"); + if (matchedPattern == 0 && exprs[2] != null && !SUPPORTS_DAMAGE_SOURCE) { + Skript.error("Using the fake cause extension in effect 'damage' requires Spigot 1.20.4+"); + return false; + } this.damageables = exprs[0]; this.isHealing = matchedPattern >= 1; this.isRepairing = matchedPattern == 2; this.amount = (Expression) exprs[1]; + if (exprs.length > 2) + this.exprCause = (Expression) exprs[2]; return true; } @@ -84,8 +79,7 @@ protected void execute(Event event) { } for (Object obj : this.damageables.getArray(event)) { - if (obj instanceof ItemType) { - ItemType itemType = (ItemType) obj; + if (obj instanceof ItemType itemType) { if (this.amount == null) { ItemUtils.setDamage(itemType, 0); @@ -93,8 +87,7 @@ protected void execute(Event event) { ItemUtils.setDamage(itemType, (int) Math2.fit(0, (ItemUtils.getDamage(itemType) + (isHealing ? -amount : amount)), ItemUtils.getMaxDamage(itemType))); } - } else if (obj instanceof Slot) { - Slot slot = (Slot) obj; + } else if (obj instanceof Slot slot) { ItemStack itemStack = slot.getItem(); if (itemStack == null) @@ -109,14 +102,19 @@ protected void execute(Event event) { slot.setItem(itemStack); - } else if (obj instanceof Damageable) { - Damageable damageable = (Damageable) obj; - + } else if (obj instanceof Damageable damageable) { if (this.amount == null) { HealthUtils.heal(damageable, HealthUtils.getMaxHealth(damageable)); } else if (isHealing) { HealthUtils.heal(damageable, amount); } else { + if (SUPPORTS_DAMAGE_SOURCE) { + DamageCause cause = exprCause == null ? null : exprCause.getSingle(event); + if (cause != null) { + HealthUtils.damage(damageable, amount, DamageUtils.getDamageSourceFromCause(cause)); + return; + } + } HealthUtils.damage(damageable, amount); } @@ -126,15 +124,15 @@ protected void execute(Event event) { @Override public String toString(@Nullable Event event, boolean debug) { - String prefix = "damage "; if (isRepairing) { prefix = "repair "; } else if (isHealing) { prefix = "heal "; } - - return prefix + damageables.toString(event, debug) + (amount != null ? " by " + amount.toString(event, debug) : ""); + return prefix + damageables.toString(event, debug) + + (amount != null ? " by " + amount.toString(event, debug) : "") + + (exprCause != null && event != null ? " with damage cause " + exprCause.getSingle(event) : ""); } } diff --git a/src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java b/src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java index b88031dead4..02a024e5a67 100644 --- a/src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java +++ b/src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/effects/EffIgnite.java b/src/main/java/ch/njol/skript/effects/EffIgnite.java index 1cd06e063ad..20392f897d3 100644 --- a/src/main/java/ch/njol/skript/effects/EffIgnite.java +++ b/src/main/java/ch/njol/skript/effects/EffIgnite.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/effects/EffIncendiary.java b/src/main/java/ch/njol/skript/effects/EffIncendiary.java index 6cd3ae4eba9..181444137cf 100644 --- a/src/main/java/ch/njol/skript/effects/EffIncendiary.java +++ b/src/main/java/ch/njol/skript/effects/EffIncendiary.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffInvisible.java b/src/main/java/ch/njol/skript/effects/EffInvisible.java index ca62a52ea8b..af8d1206ef3 100644 --- a/src/main/java/ch/njol/skript/effects/EffInvisible.java +++ b/src/main/java/ch/njol/skript/effects/EffInvisible.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffInvulnerability.java b/src/main/java/ch/njol/skript/effects/EffInvulnerability.java index 021121912ee..9585f88b97f 100644 --- a/src/main/java/ch/njol/skript/effects/EffInvulnerability.java +++ b/src/main/java/ch/njol/skript/effects/EffInvulnerability.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffKeepInventory.java b/src/main/java/ch/njol/skript/effects/EffKeepInventory.java index 3031c0a045e..3ed179e28ba 100644 --- a/src/main/java/ch/njol/skript/effects/EffKeepInventory.java +++ b/src/main/java/ch/njol/skript/effects/EffKeepInventory.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffKick.java b/src/main/java/ch/njol/skript/effects/EffKick.java index 86279643f08..ef89ad297ea 100644 --- a/src/main/java/ch/njol/skript/effects/EffKick.java +++ b/src/main/java/ch/njol/skript/effects/EffKick.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffKill.java b/src/main/java/ch/njol/skript/effects/EffKill.java index 214c847ac5c..0ecc6146756 100644 --- a/src/main/java/ch/njol/skript/effects/EffKill.java +++ b/src/main/java/ch/njol/skript/effects/EffKill.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffKnockback.java b/src/main/java/ch/njol/skript/effects/EffKnockback.java index 6d85db09198..de43ed17322 100644 --- a/src/main/java/ch/njol/skript/effects/EffKnockback.java +++ b/src/main/java/ch/njol/skript/effects/EffKnockback.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffLeash.java b/src/main/java/ch/njol/skript/effects/EffLeash.java index 305bf3959e7..4e1b0159b08 100644 --- a/src/main/java/ch/njol/skript/effects/EffLeash.java +++ b/src/main/java/ch/njol/skript/effects/EffLeash.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffLightning.java b/src/main/java/ch/njol/skript/effects/EffLightning.java index 43b630445c4..a92d6681e5c 100644 --- a/src/main/java/ch/njol/skript/effects/EffLightning.java +++ b/src/main/java/ch/njol/skript/effects/EffLightning.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/effects/EffLoadServerIcon.java b/src/main/java/ch/njol/skript/effects/EffLoadServerIcon.java index 640fdf7c4d1..93242b6bb05 100644 --- a/src/main/java/ch/njol/skript/effects/EffLoadServerIcon.java +++ b/src/main/java/ch/njol/skript/effects/EffLoadServerIcon.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.nio.file.Files; diff --git a/src/main/java/ch/njol/skript/effects/EffLog.java b/src/main/java/ch/njol/skript/effects/EffLog.java index e92d2ffa9f8..c528a09df50 100644 --- a/src/main/java/ch/njol/skript/effects/EffLog.java +++ b/src/main/java/ch/njol/skript/effects/EffLog.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.io.BufferedWriter; diff --git a/src/main/java/ch/njol/skript/effects/EffLook.java b/src/main/java/ch/njol/skript/effects/EffLook.java index 344992fd040..5b88d37a9a4 100644 --- a/src/main/java/ch/njol/skript/effects/EffLook.java +++ b/src/main/java/ch/njol/skript/effects/EffLook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffMakeEggHatch.java b/src/main/java/ch/njol/skript/effects/EffMakeEggHatch.java index 67591509ae6..44f10a91b99 100644 --- a/src/main/java/ch/njol/skript/effects/EffMakeEggHatch.java +++ b/src/main/java/ch/njol/skript/effects/EffMakeEggHatch.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffMakeFly.java b/src/main/java/ch/njol/skript/effects/EffMakeFly.java index cb4ace6c7cc..ba8812f1e45 100644 --- a/src/main/java/ch/njol/skript/effects/EffMakeFly.java +++ b/src/main/java/ch/njol/skript/effects/EffMakeFly.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; diff --git a/src/main/java/ch/njol/skript/effects/EffMakeSay.java b/src/main/java/ch/njol/skript/effects/EffMakeSay.java index 1306159703d..a509558901f 100644 --- a/src/main/java/ch/njol/skript/effects/EffMakeSay.java +++ b/src/main/java/ch/njol/skript/effects/EffMakeSay.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffMessage.java b/src/main/java/ch/njol/skript/effects/EffMessage.java index 3e5535c4082..476ecda14fc 100644 --- a/src/main/java/ch/njol/skript/effects/EffMessage.java +++ b/src/main/java/ch/njol/skript/effects/EffMessage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.util.List; diff --git a/src/main/java/ch/njol/skript/effects/EffOp.java b/src/main/java/ch/njol/skript/effects/EffOp.java index e3756945f5a..8b8ec5f9404 100644 --- a/src/main/java/ch/njol/skript/effects/EffOp.java +++ b/src/main/java/ch/njol/skript/effects/EffOp.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/ch/njol/skript/effects/EffOpenBook.java b/src/main/java/ch/njol/skript/effects/EffOpenBook.java index bde007c1751..209dab7da48 100644 --- a/src/main/java/ch/njol/skript/effects/EffOpenBook.java +++ b/src/main/java/ch/njol/skript/effects/EffOpenBook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/effects/EffOpenInventory.java b/src/main/java/ch/njol/skript/effects/EffOpenInventory.java index b9bec05c35a..29a8f59bc11 100644 --- a/src/main/java/ch/njol/skript/effects/EffOpenInventory.java +++ b/src/main/java/ch/njol/skript/effects/EffOpenInventory.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.util.Locale; diff --git a/src/main/java/ch/njol/skript/effects/EffPathfind.java b/src/main/java/ch/njol/skript/effects/EffPathfind.java index 5b336bde1f3..fed033debdf 100644 --- a/src/main/java/ch/njol/skript/effects/EffPathfind.java +++ b/src/main/java/ch/njol/skript/effects/EffPathfind.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/effects/EffPlaySound.java b/src/main/java/ch/njol/skript/effects/EffPlaySound.java index 16a1f9ddf54..f0efd49446a 100644 --- a/src/main/java/ch/njol/skript/effects/EffPlaySound.java +++ b/src/main/java/ch/njol/skript/effects/EffPlaySound.java @@ -3,11 +3,7 @@ import ch.njol.skript.Skript; import ch.njol.skript.bukkitutil.SoundUtils; import ch.njol.skript.bukkitutil.sounds.SoundReceiver; -import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Examples; -import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.RequiredPlugins; -import ch.njol.skript.doc.Since; +import ch.njol.skript.doc.*; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -23,10 +19,7 @@ import java.util.ArrayList; import java.util.List; -import java.util.Locale; import java.util.OptionalLong; -import java.util.regex.Matcher; -import java.util.regex.Pattern; @Name("Play Sound") @Description({ @@ -72,8 +65,6 @@ public class EffPlaySound extends Effect { private static final boolean ENTITY_EMITTER_SOUND = Skript.methodExists(Player.class, "playSound", Entity.class, Sound.class, SoundCategory.class, float.class, float.class); private static final boolean ENTITY_EMITTER_STRING = Skript.methodExists(Player.class, "playSound", Entity.class, String.class, SoundCategory.class, float.class, float.class); private static final boolean ENTITY_EMITTER = ENTITY_EMITTER_SOUND || ENTITY_EMITTER_STRING; - - public static final Pattern KEY_PATTERN = Pattern.compile("([a-z0-9._-]+:)?([a-z0-9/._-]+)"); static { String seedOption = HAS_SEED ? "[[with] seed %-number%] " : ""; @@ -144,25 +135,6 @@ protected void execute(Event event) { List validSounds = new ArrayList<>(); for (String sound : sounds.getArray(event)) { NamespacedKey key = SoundUtils.getKey(sound); - if (key == null) { - sound = sound.toLowerCase(Locale.ENGLISH); - Matcher keyMatcher = KEY_PATTERN.matcher(sound); - if (!keyMatcher.matches()) - continue; - try { - String namespace = keyMatcher.group(1); - String keyValue = keyMatcher.group(2); - if (namespace == null) { - key = NamespacedKey.minecraft(keyValue); - } else { - namespace = namespace.substring(0, namespace.length() - 1); - key = new NamespacedKey(namespace, keyValue); - } - } catch (IllegalArgumentException argument) { - // The user input invalid characters - } - } - if (key == null) continue; validSounds.add(key); diff --git a/src/main/java/ch/njol/skript/effects/EffPlayerInfoVisibility.java b/src/main/java/ch/njol/skript/effects/EffPlayerInfoVisibility.java index d4cf72ad4ba..b07182bad1a 100644 --- a/src/main/java/ch/njol/skript/effects/EffPlayerInfoVisibility.java +++ b/src/main/java/ch/njol/skript/effects/EffPlayerInfoVisibility.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/effects/EffPoison.java b/src/main/java/ch/njol/skript/effects/EffPoison.java index 5ca2aad6ba9..af04ccd4f13 100644 --- a/src/main/java/ch/njol/skript/effects/EffPoison.java +++ b/src/main/java/ch/njol/skript/effects/EffPoison.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/effects/EffPotion.java b/src/main/java/ch/njol/skript/effects/EffPotion.java index 6af9ad9f08d..ed347492860 100644 --- a/src/main/java/ch/njol/skript/effects/EffPotion.java +++ b/src/main/java/ch/njol/skript/effects/EffPotion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/effects/EffPush.java b/src/main/java/ch/njol/skript/effects/EffPush.java index 43fdaee2926..6dedfd3f7ca 100644 --- a/src/main/java/ch/njol/skript/effects/EffPush.java +++ b/src/main/java/ch/njol/skript/effects/EffPush.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffPvP.java b/src/main/java/ch/njol/skript/effects/EffPvP.java index e59539323e9..c97cd92e142 100644 --- a/src/main/java/ch/njol/skript/effects/EffPvP.java +++ b/src/main/java/ch/njol/skript/effects/EffPvP.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.World; diff --git a/src/main/java/ch/njol/skript/effects/EffResetTitle.java b/src/main/java/ch/njol/skript/effects/EffResetTitle.java index 72c1d900237..541038b42fb 100644 --- a/src/main/java/ch/njol/skript/effects/EffResetTitle.java +++ b/src/main/java/ch/njol/skript/effects/EffResetTitle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffRespawn.java b/src/main/java/ch/njol/skript/effects/EffRespawn.java index a439bbd016c..b0460be02d1 100644 --- a/src/main/java/ch/njol/skript/effects/EffRespawn.java +++ b/src/main/java/ch/njol/skript/effects/EffRespawn.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffReturn.java b/src/main/java/ch/njol/skript/effects/EffReturn.java index cb20b32d5c3..ab4dafbe16b 100644 --- a/src/main/java/ch/njol/skript/effects/EffReturn.java +++ b/src/main/java/ch/njol/skript/effects/EffReturn.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffRing.java b/src/main/java/ch/njol/skript/effects/EffRing.java index 3c2714ab489..ba441f9b22c 100644 --- a/src/main/java/ch/njol/skript/effects/EffRing.java +++ b/src/main/java/ch/njol/skript/effects/EffRing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffScriptFile.java b/src/main/java/ch/njol/skript/effects/EffScriptFile.java index 548c94fde2f..30a08e25294 100644 --- a/src/main/java/ch/njol/skript/effects/EffScriptFile.java +++ b/src/main/java/ch/njol/skript/effects/EffScriptFile.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/effects/EffSendBlockChange.java b/src/main/java/ch/njol/skript/effects/EffSendBlockChange.java index 315c2c7279a..d9cdbb3a4cf 100644 --- a/src/main/java/ch/njol/skript/effects/EffSendBlockChange.java +++ b/src/main/java/ch/njol/skript/effects/EffSendBlockChange.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/effects/EffSendResourcePack.java b/src/main/java/ch/njol/skript/effects/EffSendResourcePack.java index f0eafef62dc..25da37b69db 100644 --- a/src/main/java/ch/njol/skript/effects/EffSendResourcePack.java +++ b/src/main/java/ch/njol/skript/effects/EffSendResourcePack.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffSendTitle.java b/src/main/java/ch/njol/skript/effects/EffSendTitle.java index 279b1cd3415..89b8e3c6bff 100644 --- a/src/main/java/ch/njol/skript/effects/EffSendTitle.java +++ b/src/main/java/ch/njol/skript/effects/EffSendTitle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffShear.java b/src/main/java/ch/njol/skript/effects/EffShear.java index 5cc8f5004c9..0afb3b8aa60 100644 --- a/src/main/java/ch/njol/skript/effects/EffShear.java +++ b/src/main/java/ch/njol/skript/effects/EffShear.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffShoot.java b/src/main/java/ch/njol/skript/effects/EffShoot.java deleted file mode 100644 index 0c1cc223a56..00000000000 --- a/src/main/java/ch/njol/skript/effects/EffShoot.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ -package ch.njol.skript.effects; - -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; -import org.bukkit.projectiles.ProjectileSource; -import org.bukkit.event.Event; -import org.bukkit.util.Vector; -import org.jetbrains.annotations.Nullable; - -import ch.njol.skript.Skript; -import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Examples; -import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.Since; -import ch.njol.skript.entity.EntityData; -import ch.njol.skript.lang.Effect; -import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.SkriptParser.ParseResult; -import ch.njol.skript.util.Direction; -import ch.njol.util.Kleenean; - -/** - * @author Peter Güttinger - */ -@Name("Shoot") -@Description("Shoots a projectile (or any other entity) from a given entity.") -@Examples({"shoot an arrow", - "make the player shoot a creeper at speed 10", - "shoot a pig from the creeper"}) -@Since("1.4") -public class EffShoot extends Effect { - static { - Skript.registerEffect(EffShoot.class, - "shoot %entitydatas% [from %livingentities/locations%] [(at|with) (speed|velocity) %-number%] [%-direction%]", - "(make|let) %livingentities/locations% shoot %entitydatas% [(at|with) (speed|velocity) %-number%] [%-direction%]"); - } - - private final static Double DEFAULT_SPEED = 5.; - - @SuppressWarnings("null") - private Expression> types; - @SuppressWarnings("null") - private Expression shooters; - @Nullable - private Expression velocity; - @Nullable - private Expression direction; - - @Nullable - public static Entity lastSpawned = null; - - @SuppressWarnings({"unchecked", "null"}) - @Override - public boolean init(final Expression[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) { - types = (Expression>) exprs[matchedPattern]; - shooters = exprs[1 - matchedPattern]; - velocity = (Expression) exprs[2]; - direction = (Expression) exprs[3]; - return true; - } - - @SuppressWarnings("null") - @Override - protected void execute(final Event e) { - lastSpawned = null; - final Number v = velocity != null ? velocity.getSingle(e) : DEFAULT_SPEED; - if (v == null) - return; - final Direction dir = direction != null ? direction.getSingle(e) : Direction.IDENTITY; - if (dir == null) - return; - for (final Object shooter : shooters.getArray(e)) { - for (final EntityData d : types.getArray(e)) { - if (shooter instanceof LivingEntity) { - final Vector vel = dir.getDirection(((LivingEntity) shooter).getLocation()).multiply(v.doubleValue()); - final Class type = d.getType(); - if (Fireball.class.isAssignableFrom(type)) {// fireballs explode in the shooter's face by default - final Fireball projectile = (Fireball) ((LivingEntity) shooter).getWorld().spawn(((LivingEntity) shooter).getEyeLocation().add(vel.clone().normalize().multiply(0.5)), type); - projectile.setShooter((ProjectileSource) shooter); - projectile.setVelocity(vel); - lastSpawned = projectile; - } else if (Projectile.class.isAssignableFrom(type)) { - @SuppressWarnings("unchecked") - final Projectile projectile = ((LivingEntity) shooter).launchProjectile((Class) type); - set(projectile, d); - projectile.setVelocity(vel); - lastSpawned = projectile; - } else { - final Location loc = ((LivingEntity) shooter).getLocation(); - loc.setY(loc.getY() + ((LivingEntity) shooter).getEyeHeight() / 2); - final Entity projectile = d.spawn(loc); - if (projectile != null) - projectile.setVelocity(vel); - lastSpawned = projectile; - } - } else { - final Vector vel = dir.getDirection((Location) shooter).multiply(v.doubleValue()); - final Entity projectile = d.spawn((Location) shooter); - if (projectile != null) - projectile.setVelocity(vel); - lastSpawned = projectile; - } - } - } - } - - @SuppressWarnings("unchecked") - private static void set(final Entity e, final EntityData d) { - d.set((E) e); - } - - @Override - public String toString(final @Nullable Event e, final boolean debug) { - return "shoot " + types.toString(e, debug) + " from " + shooters.toString(e, debug) + (velocity != null ? " at speed " + velocity.toString(e, debug) : "") + (direction != null ? " " + direction.toString(e, debug) : ""); - } - -} diff --git a/src/main/java/ch/njol/skript/effects/EffSilence.java b/src/main/java/ch/njol/skript/effects/EffSilence.java index 1540d94f06d..ffe8a72ed85 100644 --- a/src/main/java/ch/njol/skript/effects/EffSilence.java +++ b/src/main/java/ch/njol/skript/effects/EffSilence.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffStopServer.java b/src/main/java/ch/njol/skript/effects/EffStopServer.java index 9e0ba98e24f..379891a59bf 100644 --- a/src/main/java/ch/njol/skript/effects/EffStopServer.java +++ b/src/main/java/ch/njol/skript/effects/EffStopServer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/effects/EffStopSound.java b/src/main/java/ch/njol/skript/effects/EffStopSound.java index ffc7d818e51..b6e3e69b7b7 100644 --- a/src/main/java/ch/njol/skript/effects/EffStopSound.java +++ b/src/main/java/ch/njol/skript/effects/EffStopSound.java @@ -1,29 +1,8 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; -import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Examples; -import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.RequiredPlugins; -import ch.njol.skript.doc.Since; +import ch.njol.skript.bukkitutil.SoundUtils; +import ch.njol.skript.doc.*; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -34,7 +13,6 @@ import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; -import java.util.Locale; import java.util.regex.Pattern; @Name("Stop Sound") @@ -67,11 +45,9 @@ public class EffStopSound extends Effect { ); } - @Nullable - private Expression category; + private @Nullable Expression category; - @Nullable - private Expression sounds; + private @Nullable Expression sounds; private Expression players; private boolean allSounds; @@ -102,19 +78,15 @@ protected void execute(Event event) { player.stopSound(category); } } else if (sounds != null) { - for (String sound : sounds.getArray(event)) { - try { - Sound soundEnum = Sound.valueOf(sound.toUpperCase(Locale.ENGLISH)); + for (String soundString : sounds.getArray(event)) { + Sound sound = SoundUtils.getSound(soundString); + if (sound != null) { for (Player player : targets) - player.stopSound(soundEnum, category); - - continue; - } catch (IllegalArgumentException ignored) {} - sound = sound.toLowerCase(Locale.ENGLISH); - if (!KEY_PATTERN.matcher(sound).matches()) - continue; - for (Player player : targets) - player.stopSound(sound, category); + player.stopSound(sound, category); + } else if (KEY_PATTERN.matcher(soundString).matches()) { + for (Player player : targets) + player.stopSound(soundString, category); + } } } } diff --git a/src/main/java/ch/njol/skript/effects/EffSuppressWarnings.java b/src/main/java/ch/njol/skript/effects/EffSuppressWarnings.java index 7fadcb0b33d..6893f101d9d 100644 --- a/src/main/java/ch/njol/skript/effects/EffSuppressWarnings.java +++ b/src/main/java/ch/njol/skript/effects/EffSuppressWarnings.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffSwingHand.java b/src/main/java/ch/njol/skript/effects/EffSwingHand.java index 10c91a21b89..8246eb783c6 100644 --- a/src/main/java/ch/njol/skript/effects/EffSwingHand.java +++ b/src/main/java/ch/njol/skript/effects/EffSwingHand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/effects/EffTeleport.java b/src/main/java/ch/njol/skript/effects/EffTeleport.java index fc1ff8fd71a..09afbfcd9e8 100644 --- a/src/main/java/ch/njol/skript/effects/EffTeleport.java +++ b/src/main/java/ch/njol/skript/effects/EffTeleport.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffToggle.java b/src/main/java/ch/njol/skript/effects/EffToggle.java index 065186aee56..91bcd7d4344 100644 --- a/src/main/java/ch/njol/skript/effects/EffToggle.java +++ b/src/main/java/ch/njol/skript/effects/EffToggle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import java.lang.invoke.MethodHandle; diff --git a/src/main/java/ch/njol/skript/effects/EffToggleCanPickUpItems.java b/src/main/java/ch/njol/skript/effects/EffToggleCanPickUpItems.java index 2833d8857c9..41810ff4dfe 100644 --- a/src/main/java/ch/njol/skript/effects/EffToggleCanPickUpItems.java +++ b/src/main/java/ch/njol/skript/effects/EffToggleCanPickUpItems.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffToggleFlight.java b/src/main/java/ch/njol/skript/effects/EffToggleFlight.java index 2459573f5e6..35a5375a382 100644 --- a/src/main/java/ch/njol/skript/effects/EffToggleFlight.java +++ b/src/main/java/ch/njol/skript/effects/EffToggleFlight.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/effects/EffTooltip.java b/src/main/java/ch/njol/skript/effects/EffTooltip.java index bdc17264bc4..f9fa46e7a94 100644 --- a/src/main/java/ch/njol/skript/effects/EffTooltip.java +++ b/src/main/java/ch/njol/skript/effects/EffTooltip.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffTree.java b/src/main/java/ch/njol/skript/effects/EffTree.java index 2d9f838de71..a9369177231 100644 --- a/src/main/java/ch/njol/skript/effects/EffTree.java +++ b/src/main/java/ch/njol/skript/effects/EffTree.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/effects/EffVehicle.java b/src/main/java/ch/njol/skript/effects/EffVehicle.java index cfc9f9fe2fb..39e9bd58e49 100644 --- a/src/main/java/ch/njol/skript/effects/EffVehicle.java +++ b/src/main/java/ch/njol/skript/effects/EffVehicle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/effects/EffVisualEffect.java b/src/main/java/ch/njol/skript/effects/EffVisualEffect.java index dc79b004f34..e0a6652ae09 100644 --- a/src/main/java/ch/njol/skript/effects/EffVisualEffect.java +++ b/src/main/java/ch/njol/skript/effects/EffVisualEffect.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/effects/EffWorldLoad.java b/src/main/java/ch/njol/skript/effects/EffWorldLoad.java index 50172274146..d1198a56e90 100644 --- a/src/main/java/ch/njol/skript/effects/EffWorldLoad.java +++ b/src/main/java/ch/njol/skript/effects/EffWorldLoad.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/EffWorldSave.java b/src/main/java/ch/njol/skript/effects/EffWorldSave.java index 316f8eca288..760b4459d87 100644 --- a/src/main/java/ch/njol/skript/effects/EffWorldSave.java +++ b/src/main/java/ch/njol/skript/effects/EffWorldSave.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/effects/IndeterminateDelay.java b/src/main/java/ch/njol/skript/effects/IndeterminateDelay.java index 657e901b58e..5179d20fd36 100644 --- a/src/main/java/ch/njol/skript/effects/IndeterminateDelay.java +++ b/src/main/java/ch/njol/skript/effects/IndeterminateDelay.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.effects; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/entity/AxolotlData.java b/src/main/java/ch/njol/skript/entity/AxolotlData.java index 1dbcda1374f..0fe0ae9d877 100644 --- a/src/main/java/ch/njol/skript/entity/AxolotlData.java +++ b/src/main/java/ch/njol/skript/entity/AxolotlData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/entity/BeeData.java b/src/main/java/ch/njol/skript/entity/BeeData.java index 7dcc5cb0f77..90c34f700af 100644 --- a/src/main/java/ch/njol/skript/entity/BeeData.java +++ b/src/main/java/ch/njol/skript/entity/BeeData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.Random; diff --git a/src/main/java/ch/njol/skript/entity/CatData.java b/src/main/java/ch/njol/skript/entity/CatData.java index b1b381dd1fc..aa186aeaf1e 100644 --- a/src/main/java/ch/njol/skript/entity/CatData.java +++ b/src/main/java/ch/njol/skript/entity/CatData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.registrations.Classes; diff --git a/src/main/java/ch/njol/skript/entity/CreeperData.java b/src/main/java/ch/njol/skript/entity/CreeperData.java index 523f165e7db..25aecb6d948 100644 --- a/src/main/java/ch/njol/skript/entity/CreeperData.java +++ b/src/main/java/ch/njol/skript/entity/CreeperData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Creeper; diff --git a/src/main/java/ch/njol/skript/entity/DroppedItemData.java b/src/main/java/ch/njol/skript/entity/DroppedItemData.java index aa7b4a6b8a4..ec1b330e36b 100644 --- a/src/main/java/ch/njol/skript/entity/DroppedItemData.java +++ b/src/main/java/ch/njol/skript/entity/DroppedItemData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.lang.reflect.InvocationTargetException; diff --git a/src/main/java/ch/njol/skript/entity/EndermanData.java b/src/main/java/ch/njol/skript/entity/EndermanData.java index 188c99e1159..d5e9fa8984b 100644 --- a/src/main/java/ch/njol/skript/entity/EndermanData.java +++ b/src/main/java/ch/njol/skript/entity/EndermanData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/entity/EntityData.java b/src/main/java/ch/njol/skript/entity/EntityData.java index d11bb42882c..caa391cc811 100644 --- a/src/main/java/ch/njol/skript/entity/EntityData.java +++ b/src/main/java/ch/njol/skript/entity/EntityData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.Skript; @@ -24,31 +6,18 @@ import ch.njol.skript.classes.ClassInfo; import ch.njol.skript.classes.Parser; import ch.njol.skript.classes.Serializer; -import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.Literal; -import ch.njol.skript.lang.ParseContext; -import ch.njol.skript.lang.SkriptParser; +import ch.njol.skript.lang.*; import ch.njol.skript.lang.SkriptParser.ParseResult; -import ch.njol.skript.lang.SyntaxElement; -import ch.njol.skript.lang.SyntaxElementInfo; import ch.njol.skript.lang.util.SimpleLiteral; -import ch.njol.skript.localization.Adjective; -import ch.njol.skript.localization.Language; +import ch.njol.skript.localization.*; import ch.njol.skript.localization.Language.LanguageListenerPriority; -import ch.njol.skript.localization.LanguageChangeListener; -import ch.njol.skript.localization.Message; -import ch.njol.skript.localization.Noun; import ch.njol.skript.registrations.Classes; import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; import ch.njol.util.coll.iterator.SingleItemIterator; import ch.njol.yggdrasil.Fields; import ch.njol.yggdrasil.YggdrasilSerializable.YggdrasilExtendedSerializable; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.RegionAccessor; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -687,4 +656,33 @@ protected boolean deserialize(final String s) { return world.spawn(location, type, consumer); } + /** + * Creates an entity in the server but does not spawn it + * + * @return The created entity + */ + public @Nullable E create() { + Location location = Bukkit.getWorlds().get(0).getSpawnLocation(); + return create(location); + } + + /** + * Creates an entity at the provided location, but does not spawn it + * NOTE: If {@link RegionAccessor#createEntity(Location, Class)} does not exist, will return {@link #spawn(Location)} + * @param location The {@link Location} to create the entity at + * @return The created entity + */ + public @Nullable E create(Location location) { + if (!Skript.methodExists(RegionAccessor.class, "createEntity")) + return spawn(location); + return create(location, getType()); + } + + protected static @Nullable E create(Location location, Class type) { + World world = location.getWorld(); + if (world == null) + return null; + return world.createEntity(location, type); + } + } diff --git a/src/main/java/ch/njol/skript/entity/EntityType.java b/src/main/java/ch/njol/skript/entity/EntityType.java index dad96cad68f..9919d1956ad 100644 --- a/src/main/java/ch/njol/skript/entity/EntityType.java +++ b/src/main/java/ch/njol/skript/entity/EntityType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/entity/FallingBlockData.java b/src/main/java/ch/njol/skript/entity/FallingBlockData.java index c67b624c69f..7502805482d 100644 --- a/src/main/java/ch/njol/skript/entity/FallingBlockData.java +++ b/src/main/java/ch/njol/skript/entity/FallingBlockData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/entity/FoxData.java b/src/main/java/ch/njol/skript/entity/FoxData.java index ab2c67c1739..ea2328b3dd4 100644 --- a/src/main/java/ch/njol/skript/entity/FoxData.java +++ b/src/main/java/ch/njol/skript/entity/FoxData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Fox; diff --git a/src/main/java/ch/njol/skript/entity/FrogData.java b/src/main/java/ch/njol/skript/entity/FrogData.java index 9a0c8a4f82c..7eb9ace9858 100644 --- a/src/main/java/ch/njol/skript/entity/FrogData.java +++ b/src/main/java/ch/njol/skript/entity/FrogData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/entity/GoatData.java b/src/main/java/ch/njol/skript/entity/GoatData.java index cf70bc73c79..44140d40340 100644 --- a/src/main/java/ch/njol/skript/entity/GoatData.java +++ b/src/main/java/ch/njol/skript/entity/GoatData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/entity/LlamaData.java b/src/main/java/ch/njol/skript/entity/LlamaData.java index c5bda24d6f7..85bdea2f2fb 100644 --- a/src/main/java/ch/njol/skript/entity/LlamaData.java +++ b/src/main/java/ch/njol/skript/entity/LlamaData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Llama; diff --git a/src/main/java/ch/njol/skript/entity/MinecartData.java b/src/main/java/ch/njol/skript/entity/MinecartData.java index e96540dbded..377c2a4be3b 100644 --- a/src/main/java/ch/njol/skript/entity/MinecartData.java +++ b/src/main/java/ch/njol/skript/entity/MinecartData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/entity/MooshroomData.java b/src/main/java/ch/njol/skript/entity/MooshroomData.java index f54bbd754ae..79d2958fdca 100644 --- a/src/main/java/ch/njol/skript/entity/MooshroomData.java +++ b/src/main/java/ch/njol/skript/entity/MooshroomData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.MushroomCow; diff --git a/src/main/java/ch/njol/skript/entity/OcelotData.java b/src/main/java/ch/njol/skript/entity/OcelotData.java index 8d0eace2ec9..c845fefffcb 100644 --- a/src/main/java/ch/njol/skript/entity/OcelotData.java +++ b/src/main/java/ch/njol/skript/entity/OcelotData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Ocelot; diff --git a/src/main/java/ch/njol/skript/entity/PandaData.java b/src/main/java/ch/njol/skript/entity/PandaData.java index ea74e337b65..bc704b045ce 100644 --- a/src/main/java/ch/njol/skript/entity/PandaData.java +++ b/src/main/java/ch/njol/skript/entity/PandaData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.concurrent.ThreadLocalRandom; diff --git a/src/main/java/ch/njol/skript/entity/ParrotData.java b/src/main/java/ch/njol/skript/entity/ParrotData.java index e512af6eff3..7a151c2512f 100644 --- a/src/main/java/ch/njol/skript/entity/ParrotData.java +++ b/src/main/java/ch/njol/skript/entity/ParrotData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.concurrent.ThreadLocalRandom; diff --git a/src/main/java/ch/njol/skript/entity/PigData.java b/src/main/java/ch/njol/skript/entity/PigData.java index 8ce406a705a..42713e1cd4d 100644 --- a/src/main/java/ch/njol/skript/entity/PigData.java +++ b/src/main/java/ch/njol/skript/entity/PigData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Pig; diff --git a/src/main/java/ch/njol/skript/entity/RabbitData.java b/src/main/java/ch/njol/skript/entity/RabbitData.java index 49208e3eebe..3db721d73cf 100644 --- a/src/main/java/ch/njol/skript/entity/RabbitData.java +++ b/src/main/java/ch/njol/skript/entity/RabbitData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Rabbit; diff --git a/src/main/java/ch/njol/skript/entity/SheepData.java b/src/main/java/ch/njol/skript/entity/SheepData.java index 119daf8c65f..26e6e351204 100644 --- a/src/main/java/ch/njol/skript/entity/SheepData.java +++ b/src/main/java/ch/njol/skript/entity/SheepData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/entity/SimpleEntityData.java b/src/main/java/ch/njol/skript/entity/SimpleEntityData.java index 59bdd3e0793..3509ab31ff7 100644 --- a/src/main/java/ch/njol/skript/entity/SimpleEntityData.java +++ b/src/main/java/ch/njol/skript/entity/SimpleEntityData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/entity/ThrownPotionData.java b/src/main/java/ch/njol/skript/entity/ThrownPotionData.java index 22ec2711951..30a832ee5f7 100644 --- a/src/main/java/ch/njol/skript/entity/ThrownPotionData.java +++ b/src/main/java/ch/njol/skript/entity/ThrownPotionData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/entity/TropicalFishData.java b/src/main/java/ch/njol/skript/entity/TropicalFishData.java index b8266a09537..8b173e73914 100644 --- a/src/main/java/ch/njol/skript/entity/TropicalFishData.java +++ b/src/main/java/ch/njol/skript/entity/TropicalFishData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.Objects; diff --git a/src/main/java/ch/njol/skript/entity/VillagerData.java b/src/main/java/ch/njol/skript/entity/VillagerData.java index 3e1cb593de7..7231e4637c5 100644 --- a/src/main/java/ch/njol/skript/entity/VillagerData.java +++ b/src/main/java/ch/njol/skript/entity/VillagerData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.lang.invoke.MethodHandles; diff --git a/src/main/java/ch/njol/skript/entity/WolfData.java b/src/main/java/ch/njol/skript/entity/WolfData.java index eb5ff6ba8a1..d79ebd79591 100644 --- a/src/main/java/ch/njol/skript/entity/WolfData.java +++ b/src/main/java/ch/njol/skript/entity/WolfData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import ch.njol.skript.bukkitutil.BukkitUtils; diff --git a/src/main/java/ch/njol/skript/entity/XpOrbData.java b/src/main/java/ch/njol/skript/entity/XpOrbData.java index 47dcce369fe..c2e80e7b5ba 100644 --- a/src/main/java/ch/njol/skript/entity/XpOrbData.java +++ b/src/main/java/ch/njol/skript/entity/XpOrbData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import java.util.function.Consumer; diff --git a/src/main/java/ch/njol/skript/entity/ZombieVillagerData.java b/src/main/java/ch/njol/skript/entity/ZombieVillagerData.java index 6b50870dd7e..63b36d1fd8a 100644 --- a/src/main/java/ch/njol/skript/entity/ZombieVillagerData.java +++ b/src/main/java/ch/njol/skript/entity/ZombieVillagerData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.entity; import org.bukkit.entity.Villager; diff --git a/src/main/java/ch/njol/skript/events/EvtAtTime.java b/src/main/java/ch/njol/skript/events/EvtAtTime.java index c7adae44144..0cbc5f96bef 100644 --- a/src/main/java/ch/njol/skript/events/EvtAtTime.java +++ b/src/main/java/ch/njol/skript/events/EvtAtTime.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtBlock.java b/src/main/java/ch/njol/skript/events/EvtBlock.java index 33fef59ea7f..c135df27a04 100644 --- a/src/main/java/ch/njol/skript/events/EvtBlock.java +++ b/src/main/java/ch/njol/skript/events/EvtBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.block.Block; diff --git a/src/main/java/ch/njol/skript/events/EvtBookEdit.java b/src/main/java/ch/njol/skript/events/EvtBookEdit.java index afca696b971..17d67baa28e 100644 --- a/src/main/java/ch/njol/skript/events/EvtBookEdit.java +++ b/src/main/java/ch/njol/skript/events/EvtBookEdit.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtBookSign.java b/src/main/java/ch/njol/skript/events/EvtBookSign.java index 4f29a14d1ba..58c2cd61444 100644 --- a/src/main/java/ch/njol/skript/events/EvtBookSign.java +++ b/src/main/java/ch/njol/skript/events/EvtBookSign.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtCommand.java b/src/main/java/ch/njol/skript/events/EvtCommand.java index 5a62df6d0d6..3af29b9979e 100644 --- a/src/main/java/ch/njol/skript/events/EvtCommand.java +++ b/src/main/java/ch/njol/skript/events/EvtCommand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtDamage.java b/src/main/java/ch/njol/skript/events/EvtDamage.java index ef849c5478c..60fafa120fb 100644 --- a/src/main/java/ch/njol/skript/events/EvtDamage.java +++ b/src/main/java/ch/njol/skript/events/EvtDamage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.entity.EnderDragon; diff --git a/src/main/java/ch/njol/skript/events/EvtEntity.java b/src/main/java/ch/njol/skript/events/EvtEntity.java index fc8110b7a23..bfbef66a66c 100644 --- a/src/main/java/ch/njol/skript/events/EvtEntity.java +++ b/src/main/java/ch/njol/skript/events/EvtEntity.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/events/EvtEntityBlockChange.java b/src/main/java/ch/njol/skript/events/EvtEntityBlockChange.java index 9854057db03..aa09ffcdf52 100644 --- a/src/main/java/ch/njol/skript/events/EvtEntityBlockChange.java +++ b/src/main/java/ch/njol/skript/events/EvtEntityBlockChange.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtEntityPotion.java b/src/main/java/ch/njol/skript/events/EvtEntityPotion.java index ab56287ef2b..d0655dfb491 100644 --- a/src/main/java/ch/njol/skript/events/EvtEntityPotion.java +++ b/src/main/java/ch/njol/skript/events/EvtEntityPotion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtEntityTarget.java b/src/main/java/ch/njol/skript/events/EvtEntityTarget.java index b1b5ec31598..10fb2ddfdba 100644 --- a/src/main/java/ch/njol/skript/events/EvtEntityTarget.java +++ b/src/main/java/ch/njol/skript/events/EvtEntityTarget.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtEntityTransform.java b/src/main/java/ch/njol/skript/events/EvtEntityTransform.java index 4cd709e89a2..18a8b137eba 100644 --- a/src/main/java/ch/njol/skript/events/EvtEntityTransform.java +++ b/src/main/java/ch/njol/skript/events/EvtEntityTransform.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtExperienceChange.java b/src/main/java/ch/njol/skript/events/EvtExperienceChange.java index ed48015101f..6ee2824c48f 100644 --- a/src/main/java/ch/njol/skript/events/EvtExperienceChange.java +++ b/src/main/java/ch/njol/skript/events/EvtExperienceChange.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtExperienceSpawn.java b/src/main/java/ch/njol/skript/events/EvtExperienceSpawn.java index a40b10fcec3..3caaf2a10ab 100644 --- a/src/main/java/ch/njol/skript/events/EvtExperienceSpawn.java +++ b/src/main/java/ch/njol/skript/events/EvtExperienceSpawn.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtFirstJoin.java b/src/main/java/ch/njol/skript/events/EvtFirstJoin.java index 2fd7a2cfea1..ef5e6e68c15 100644 --- a/src/main/java/ch/njol/skript/events/EvtFirstJoin.java +++ b/src/main/java/ch/njol/skript/events/EvtFirstJoin.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtGameMode.java b/src/main/java/ch/njol/skript/events/EvtGameMode.java index 2437384198b..26eaf30d5ec 100644 --- a/src/main/java/ch/njol/skript/events/EvtGameMode.java +++ b/src/main/java/ch/njol/skript/events/EvtGameMode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import java.util.Locale; diff --git a/src/main/java/ch/njol/skript/events/EvtGrow.java b/src/main/java/ch/njol/skript/events/EvtGrow.java index d022e020b61..f5bdc5a6629 100644 --- a/src/main/java/ch/njol/skript/events/EvtGrow.java +++ b/src/main/java/ch/njol/skript/events/EvtGrow.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtHealing.java b/src/main/java/ch/njol/skript/events/EvtHealing.java index c40f4d31b37..95c530adaaf 100644 --- a/src/main/java/ch/njol/skript/events/EvtHealing.java +++ b/src/main/java/ch/njol/skript/events/EvtHealing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/events/EvtItem.java b/src/main/java/ch/njol/skript/events/EvtItem.java index 5dd9b8014ae..c648674173b 100644 --- a/src/main/java/ch/njol/skript/events/EvtItem.java +++ b/src/main/java/ch/njol/skript/events/EvtItem.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent; diff --git a/src/main/java/ch/njol/skript/events/EvtLevel.java b/src/main/java/ch/njol/skript/events/EvtLevel.java index cbfbd42014f..3a4ac483f70 100644 --- a/src/main/java/ch/njol/skript/events/EvtLevel.java +++ b/src/main/java/ch/njol/skript/events/EvtLevel.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtMove.java b/src/main/java/ch/njol/skript/events/EvtMove.java index 0eec1d9aa1c..9c832abe183 100644 --- a/src/main/java/ch/njol/skript/events/EvtMove.java +++ b/src/main/java/ch/njol/skript/events/EvtMove.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtMoveOn.java b/src/main/java/ch/njol/skript/events/EvtMoveOn.java index efa84ad3db6..49304a4da0b 100644 --- a/src/main/java/ch/njol/skript/events/EvtMoveOn.java +++ b/src/main/java/ch/njol/skript/events/EvtMoveOn.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtPeriodical.java b/src/main/java/ch/njol/skript/events/EvtPeriodical.java index 1167743b2c9..82dc65756da 100644 --- a/src/main/java/ch/njol/skript/events/EvtPeriodical.java +++ b/src/main/java/ch/njol/skript/events/EvtPeriodical.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtPlantGrowth.java b/src/main/java/ch/njol/skript/events/EvtPlantGrowth.java index 7e9df973c5a..c000ab081df 100644 --- a/src/main/java/ch/njol/skript/events/EvtPlantGrowth.java +++ b/src/main/java/ch/njol/skript/events/EvtPlantGrowth.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtPlayerChunkEnter.java b/src/main/java/ch/njol/skript/events/EvtPlayerChunkEnter.java index 0507cefeb35..13c6f53b164 100644 --- a/src/main/java/ch/njol/skript/events/EvtPlayerChunkEnter.java +++ b/src/main/java/ch/njol/skript/events/EvtPlayerChunkEnter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtPlayerCommandSend.java b/src/main/java/ch/njol/skript/events/EvtPlayerCommandSend.java index b2d094ba8b1..10d09e1b20c 100644 --- a/src/main/java/ch/njol/skript/events/EvtPlayerCommandSend.java +++ b/src/main/java/ch/njol/skript/events/EvtPlayerCommandSend.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtPressurePlate.java b/src/main/java/ch/njol/skript/events/EvtPressurePlate.java index 5995f2dd167..a68d9252680 100644 --- a/src/main/java/ch/njol/skript/events/EvtPressurePlate.java +++ b/src/main/java/ch/njol/skript/events/EvtPressurePlate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/events/EvtResourcePackResponse.java b/src/main/java/ch/njol/skript/events/EvtResourcePackResponse.java index 3a5c7fa6bd5..1cc504740b5 100644 --- a/src/main/java/ch/njol/skript/events/EvtResourcePackResponse.java +++ b/src/main/java/ch/njol/skript/events/EvtResourcePackResponse.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtScript.java b/src/main/java/ch/njol/skript/events/EvtScript.java index d966c894479..347e7ee1d44 100644 --- a/src/main/java/ch/njol/skript/events/EvtScript.java +++ b/src/main/java/ch/njol/skript/events/EvtScript.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtSkript.java b/src/main/java/ch/njol/skript/events/EvtSkript.java index 258ca71b192..a04a16ca7a5 100644 --- a/src/main/java/ch/njol/skript/events/EvtSkript.java +++ b/src/main/java/ch/njol/skript/events/EvtSkript.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtSpectate.java b/src/main/java/ch/njol/skript/events/EvtSpectate.java index b3c1d9c1191..5d778f557bb 100644 --- a/src/main/java/ch/njol/skript/events/EvtSpectate.java +++ b/src/main/java/ch/njol/skript/events/EvtSpectate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/events/EvtTeleport.java b/src/main/java/ch/njol/skript/events/EvtTeleport.java index 6ff92b6d642..1855182c8e3 100644 --- a/src/main/java/ch/njol/skript/events/EvtTeleport.java +++ b/src/main/java/ch/njol/skript/events/EvtTeleport.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/EvtWeatherChange.java b/src/main/java/ch/njol/skript/events/EvtWeatherChange.java index 26e1442f003..f68dd416eaa 100644 --- a/src/main/java/ch/njol/skript/events/EvtWeatherChange.java +++ b/src/main/java/ch/njol/skript/events/EvtWeatherChange.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/EvtWorld.java b/src/main/java/ch/njol/skript/events/EvtWorld.java index 1bbe0a21802..82d8bc9a12e 100644 --- a/src/main/java/ch/njol/skript/events/EvtWorld.java +++ b/src/main/java/ch/njol/skript/events/EvtWorld.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/events/SimpleEvents.java b/src/main/java/ch/njol/skript/events/SimpleEvents.java index f116ea623b8..9997a21405b 100644 --- a/src/main/java/ch/njol/skript/events/SimpleEvents.java +++ b/src/main/java/ch/njol/skript/events/SimpleEvents.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events; import ch.njol.skript.Skript; @@ -25,6 +7,7 @@ import com.destroystokyo.paper.event.entity.EntityJumpEvent; import com.destroystokyo.paper.event.entity.ProjectileCollideEvent; import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; +import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; import com.destroystokyo.paper.event.player.PlayerJumpEvent; import com.destroystokyo.paper.event.player.PlayerReadyArrowEvent; import com.destroystokyo.paper.event.server.PaperServerListPingEvent; @@ -150,14 +133,6 @@ public class SimpleEvents { .description("Called when the hunger bar of a player changes, i.e. either increases by eating or decreases over time.") .examples("on food bar change:") .since("1.4.4"); - Skript.registerEvent("Fuel Burn", SimpleEvent.class, FurnaceBurnEvent.class, "fuel burn[ing]") - .description("Called when a furnace burns an item from its fuel slot.") - .examples("on fuel burning:") - .since("1.0"); - Skript.registerEvent("Smelt", SimpleEvent.class, FurnaceSmeltEvent.class, "[ore] smelt[ing]", "smelt[ing] of ore") //TODO SkriptEvent for "smelt[ing] of %itemtype%" - .description("Called when a furnace smelts an item in its ore slot.") - .examples("on smelt:") - .since("1.0"); Skript.registerEvent("Leaves Decay", SimpleEvent.class, LeavesDecayEvent.class, "leaves decay[ing]") .description("Called when a leaf block decays due to not being connected to a tree.") .examples("on leaves decay:") @@ -620,21 +595,7 @@ public class SimpleEvents { "\t\tset chat format to \"<orange>[player]<light gray>: <white>[message]\"" ) .since("1.4.1"); - if (Skript.classExists("org.bukkit.event.world.LootGenerateEvent")) { - Skript.registerEvent("Loot Generate", SimpleEvent.class, LootGenerateEvent.class, "loot generat(e|ing)") - .description( - "Called when a loot table of an inventory is generated in the world.", - "For example, when opening a shipwreck chest." - ) - .examples( - "on loot generate:", - "\tchance of 10%", - "\tadd 64 diamonds to the loot", - "\tsend \"You hit the jackpot at %event-location%!\"" - ) - .since("2.7") - .requiredPlugins("MC 1.16+"); - } + if (Skript.classExists("io.papermc.paper.event.player.PlayerDeepSleepEvent")) { Skript.registerEvent("Player Deep Sleep", SimpleEvent.class, PlayerDeepSleepEvent.class, "[player] deep sleep[ing]") .description( @@ -790,6 +751,18 @@ public class SimpleEvents { ) .since("INSERT VERSION"); + if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) { + Skript.registerEvent("Elytra Boost", SimpleEvent.class, PlayerElytraBoostEvent.class, "elytra boost") + .description("Called when a player uses a firework to boost their fly speed when flying with an elytra.") + .examples( + "on elytra boost:", + "\tif the used firework will be consumed:", + "\t\tprevent the used firework from being consume" + ) + .requiredPlugins("Paper") + .since("INSERT VERSION"); + } + } } diff --git a/src/main/java/ch/njol/skript/events/bukkit/ExperienceSpawnEvent.java b/src/main/java/ch/njol/skript/events/bukkit/ExperienceSpawnEvent.java index 2b357bedf75..e4a4e315f87 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/ExperienceSpawnEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/ExperienceSpawnEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/events/bukkit/PreScriptLoadEvent.java b/src/main/java/ch/njol/skript/events/bukkit/PreScriptLoadEvent.java index 4301566bc98..7237cb0f07e 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/PreScriptLoadEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/PreScriptLoadEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import java.util.List; diff --git a/src/main/java/ch/njol/skript/events/bukkit/ScheduledEvent.java b/src/main/java/ch/njol/skript/events/bukkit/ScheduledEvent.java index bfc1346357d..7a08605ad5b 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/ScheduledEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/ScheduledEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import org.bukkit.World; diff --git a/src/main/java/ch/njol/skript/events/bukkit/ScheduledNoWorldEvent.java b/src/main/java/ch/njol/skript/events/bukkit/ScheduledNoWorldEvent.java index b27fa0de11f..204907f0fe7 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/ScheduledNoWorldEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/ScheduledNoWorldEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import org.bukkit.event.HandlerList; diff --git a/src/main/java/ch/njol/skript/events/bukkit/ScriptEvent.java b/src/main/java/ch/njol/skript/events/bukkit/ScriptEvent.java index 31947ee2f51..7222af52693 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/ScriptEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/ScriptEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/bukkit/SkriptStartEvent.java b/src/main/java/ch/njol/skript/events/bukkit/SkriptStartEvent.java index a36ba3d32c4..b12c7ed1008 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/SkriptStartEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/SkriptStartEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/events/bukkit/SkriptStopEvent.java b/src/main/java/ch/njol/skript/events/bukkit/SkriptStopEvent.java index 0536891da09..bdaad4f9c97 100644 --- a/src/main/java/ch/njol/skript/events/bukkit/SkriptStopEvent.java +++ b/src/main/java/ch/njol/skript/events/bukkit/SkriptStopEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.events.bukkit; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAI.java b/src/main/java/ch/njol/skript/expressions/ExprAI.java index 379337054bd..ae3ad17dc9c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAI.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAI.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAbsorbedBlocks.java b/src/main/java/ch/njol/skript/expressions/ExprAbsorbedBlocks.java index 1becb4a8283..c436a0474c6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAbsorbedBlocks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAbsorbedBlocks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/expressions/ExprActiveItem.java b/src/main/java/ch/njol/skript/expressions/ExprActiveItem.java index 0e9f6cd2098..197db86faca 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprActiveItem.java +++ b/src/main/java/ch/njol/skript/expressions/ExprActiveItem.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAffectedEntities.java b/src/main/java/ch/njol/skript/expressions/ExprAffectedEntities.java index 71ae9176e06..66393d7ead4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAffectedEntities.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAffectedEntities.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAge.java b/src/main/java/ch/njol/skript/expressions/ExprAge.java index 8f4c1fa2489..a93f78b97fe 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAge.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAge.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAllBannedEntries.java b/src/main/java/ch/njol/skript/expressions/ExprAllBannedEntries.java index 77a5e214360..0733cc9cf34 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAllBannedEntries.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAllBannedEntries.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAllCommands.java b/src/main/java/ch/njol/skript/expressions/ExprAllCommands.java index 19791ae84b3..389c259dbe6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAllCommands.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAllCommands.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAlphabetList.java b/src/main/java/ch/njol/skript/expressions/ExprAlphabetList.java index f3585c2e123..fa02485b2b7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAlphabetList.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAlphabetList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAltitude.java b/src/main/java/ch/njol/skript/expressions/ExprAltitude.java index 0f2ba03f71a..c8f39fc8fd1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAltitude.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAltitude.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAmount.java b/src/main/java/ch/njol/skript/expressions/ExprAmount.java index d8c226dc00d..06abd492dc2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAmount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAmount.java @@ -1,24 +1,7 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Name; @@ -30,18 +13,20 @@ import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.Variable; import ch.njol.skript.lang.util.SimpleExpression; +import ch.njol.skript.lang.util.common.AnyAmount; import ch.njol.util.Kleenean; +import ch.njol.util.coll.CollectionUtils; import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; import java.util.Map; /** - * + * * @author Peter Güttinger */ @Name("Amount") -@Description({"The amount of something.", +@Description({"The amount or size of something.", "Please note that amount of %items% will not return the number of items, but the number of stacks, e.g. 1 for a stack of 64 torches. To get the amount of items in a stack, see the item amount expression.", "", "Also, you can get the recursive size of a list, which will return the recursive size of the list with sublists included, e.g.", @@ -60,23 +45,30 @@ "Please note that getting a list's recursive size can cause lag if the list is large, so only use this expression if you need to!"}) @Examples({"message \"There are %number of all players% players online!\""}) @Since("1.0") -public class ExprAmount extends SimpleExpression { +public class ExprAmount extends SimpleExpression { static { - Skript.registerExpression(ExprAmount.class, Long.class, ExpressionType.PROPERTY, + Skript.registerExpression(ExprAmount.class, Number.class, ExpressionType.PROPERTY, + "[the] (amount|number|size) of %numbered%", "[the] (amount|number|size) of %objects%", "[the] recursive (amount|number|size) of %objects%"); } @SuppressWarnings("null") private ExpressionList exprs; + private @Nullable Expression any; private boolean recursive; @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + if (matchedPattern == 0) { + //noinspection unchecked + this.any = (Expression) exprs[0]; + return true; + } this.exprs = exprs[0] instanceof ExpressionList ? (ExpressionList) exprs[0] : new ExpressionList<>(new Expression[]{exprs[0]}, Object.class, false); - this.recursive = matchedPattern == 1; + this.recursive = matchedPattern == 2; for (Expression expr : this.exprs.getExpressions()) { if (expr instanceof Literal) { return false; @@ -95,7 +87,9 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override @SuppressWarnings("unchecked") - protected Long[] get(Event e) { + protected Number[] get(Event e) { + if (any != null) + return new Number[] {any.getOptionalSingle(e).orElse(() -> 0).amount()}; if (recursive) { int currentSize = 0; for (Expression expr : exprs.getExpressions()) { @@ -109,6 +103,45 @@ protected Long[] get(Event e) { return new Long[]{(long) exprs.getArray(e).length}; } + @Override + public @Nullable Class[] acceptChange(ChangeMode mode) { + if (any != null) { + return switch (mode) { + case SET, ADD, RESET, DELETE, REMOVE -> CollectionUtils.array(Number.class); + default -> null; + }; + } + return super.acceptChange(mode); + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (any == null) { + super.change(event, delta, mode); + return; + } + double amount = delta != null ? ((Number) delta[0]).doubleValue() : 1; + // It's okay to treat it as a double even if it's a whole number because there's no case in + // the set of real numbers where (x->double + y->double)->long != (x+y) + switch (mode) { + case REMOVE: + amount = -amount; + //$FALL-THROUGH$ + case ADD: + for (AnyAmount obj : any.getArray(event)) { + if (obj.supportsAmountChange()) + obj.setAmount(obj.amount().doubleValue() + amount); + } + break; + case RESET, DELETE, SET: + for (AnyAmount any : any.getArray(event)) { + if (any.supportsAmountChange()) + any.setAmount(amount); + } + break; + } + } + @SuppressWarnings("unchecked") private static int getRecursiveSize(Map map) { int count = 0; @@ -128,13 +161,15 @@ public boolean isSingle() { } @Override - public Class getReturnType() { - return Long.class; + public Class getReturnType() { + return any != null ? Number.class : Long.class; } @Override - public String toString(@Nullable Event e, boolean debug) { - return (recursive ? "recursive size of " : "amount of ") + exprs.toString(e, debug); + public String toString(@Nullable Event event, boolean debug) { + if (any != null) + return "amount of " + any.toString(event, debug); + return (recursive ? "recursive size of " : "amount of ") + exprs.toString(event, debug); } } diff --git a/src/main/java/ch/njol/skript/expressions/ExprAmountOfItems.java b/src/main/java/ch/njol/skript/expressions/ExprAmountOfItems.java index 2d43acf4111..c5d378e3a07 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAmountOfItems.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAmountOfItems.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAnvilRepairCost.java b/src/main/java/ch/njol/skript/expressions/ExprAnvilRepairCost.java index 06887b09cb9..8a0e42c74e0 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAnvilRepairCost.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAnvilRepairCost.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAnvilText.java b/src/main/java/ch/njol/skript/expressions/ExprAnvilText.java index d894368535e..87175db6252 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAnvilText.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAnvilText.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAppliedEnchantments.java b/src/main/java/ch/njol/skript/expressions/ExprAppliedEnchantments.java index 85970776262..f2b0b79ee11 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAppliedEnchantments.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAppliedEnchantments.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.enchantments.Enchantment; diff --git a/src/main/java/ch/njol/skript/expressions/ExprArgument.java b/src/main/java/ch/njol/skript/expressions/ExprArgument.java index 56ef0c1165a..db91407e222 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprArgument.java +++ b/src/main/java/ch/njol/skript/expressions/ExprArgument.java @@ -1,26 +1,10 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.List; import java.util.regex.MatchResult; +import ch.njol.skript.lang.EventRestrictedSyntax; +import ch.njol.util.coll.CollectionUtils; import org.bukkit.event.Event; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.server.ServerCommandEvent; @@ -61,7 +45,7 @@ "heal the last argument" }) @Since("1.0, 2.7 (support for command events)") -public class ExprArgument extends SimpleExpression { +public class ExprArgument extends SimpleExpression implements EventRestrictedSyntax { static { Skript.registerExpression(ExprArgument.class, Object.class, ExpressionType.SIMPLE, @@ -86,10 +70,6 @@ public class ExprArgument extends SimpleExpression { @SuppressWarnings("unchecked") public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { boolean scriptCommand = getParser().isCurrentEvent(ScriptCommandEvent.class); - if (!scriptCommand && !getParser().isCurrentEvent(PlayerCommandPreprocessEvent.class, ServerCommandEvent.class)) { - Skript.error("The 'argument' expression can only be used in a script command or command event"); - return false; - } switch (matchedPattern) { case 0: @@ -210,7 +190,13 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye return true; } - + + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(ScriptCommandEvent.class, PlayerCommandPreprocessEvent.class, + ServerCommandEvent.class); + } + @Override @Nullable protected Object[] get(final Event e) { diff --git a/src/main/java/ch/njol/skript/expressions/ExprArmorSlot.java b/src/main/java/ch/njol/skript/expressions/ExprArmorSlot.java index 884cc629639..38332c8823e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprArmorSlot.java +++ b/src/main/java/ch/njol/skript/expressions/ExprArmorSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprArrowKnockbackStrength.java b/src/main/java/ch/njol/skript/expressions/ExprArrowKnockbackStrength.java index 3127327d580..3c72322131b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprArrowKnockbackStrength.java +++ b/src/main/java/ch/njol/skript/expressions/ExprArrowKnockbackStrength.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.AbstractArrow; diff --git a/src/main/java/ch/njol/skript/expressions/ExprArrowPierceLevel.java b/src/main/java/ch/njol/skript/expressions/ExprArrowPierceLevel.java index 0f0f777234c..1e6e205dc90 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprArrowPierceLevel.java +++ b/src/main/java/ch/njol/skript/expressions/ExprArrowPierceLevel.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Arrow; diff --git a/src/main/java/ch/njol/skript/expressions/ExprArrowsStuck.java b/src/main/java/ch/njol/skript/expressions/ExprArrowsStuck.java index 5154ef23db4..edf02dcd851 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprArrowsStuck.java +++ b/src/main/java/ch/njol/skript/expressions/ExprArrowsStuck.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAttachedBlock.java b/src/main/java/ch/njol/skript/expressions/ExprAttachedBlock.java index 19ae309cca9..5eab6b5d8a6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAttachedBlock.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAttachedBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAttackCooldown.java b/src/main/java/ch/njol/skript/expressions/ExprAttackCooldown.java index 9d58cfe0ebd..a2a7663a137 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAttackCooldown.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAttackCooldown.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprAttacked.java b/src/main/java/ch/njol/skript/expressions/ExprAttacked.java index 61e7b6e67d7..5b2ed4e51cb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAttacked.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAttacked.java @@ -1,25 +1,9 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.lang.reflect.Array; +import ch.njol.skript.lang.EventRestrictedSyntax; +import ch.njol.util.coll.CollectionUtils; import org.bukkit.entity.Entity; import org.bukkit.event.Event; import org.bukkit.event.entity.EntityDamageEvent; @@ -54,7 +38,7 @@ "\tdamage the attacked by 1 heart"}) @Since("1.3, 2.6.1 (projectile hit event)") @Events({"damage", "death", "projectile hit"}) -public class ExprAttacked extends SimpleExpression { +public class ExprAttacked extends SimpleExpression implements EventRestrictedSyntax { private static final boolean SUPPORT_PROJECTILE_HIT = Skript.methodExists(ProjectileHitEvent.class, "getHitEntity"); @@ -67,11 +51,6 @@ public class ExprAttacked extends SimpleExpression { @Override public boolean init(Expression[] vars, int matchedPattern, Kleenean isDelayed, ParseResult parser) { - if (!getParser().isCurrentEvent(EntityDamageEvent.class, EntityDeathEvent.class, VehicleDamageEvent.class, VehicleDestroyEvent.class, ProjectileHitEvent.class) - || !SUPPORT_PROJECTILE_HIT && getParser().isCurrentEvent(ProjectileHitEvent.class)) { - Skript.error("The expression 'victim' can only be used in a damage" + (SUPPORT_PROJECTILE_HIT ? ", death, or projectile hit" : " or death") + " event"); - return false; - } String type = parser.regexes.size() == 0 ? null : parser.regexes.get(0).group(); if (type == null) { this.type = EntityData.fromClass(Entity.class); @@ -86,6 +65,12 @@ public boolean init(Expression[] vars, int matchedPattern, Kleenean isDelayed return true; } + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(EntityDamageEvent.class, EntityDeathEvent.class, + VehicleDamageEvent.class, VehicleDestroyEvent.class, ProjectileHitEvent.class); + } + @Override @Nullable protected Entity[] get(Event e) { diff --git a/src/main/java/ch/njol/skript/expressions/ExprAttacker.java b/src/main/java/ch/njol/skript/expressions/ExprAttacker.java index db2e689f7a1..bf1e6d9f20e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprAttacker.java +++ b/src/main/java/ch/njol/skript/expressions/ExprAttacker.java @@ -1,23 +1,7 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; +import ch.njol.skript.lang.EventRestrictedSyntax; +import ch.njol.util.coll.CollectionUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; import org.bukkit.event.Event; @@ -54,7 +38,7 @@ " damage victim by 1 heart"}) @Since("1.3") @Events({"damage", "death", "destroy"}) -public class ExprAttacker extends SimpleExpression { +public class ExprAttacker extends SimpleExpression implements EventRestrictedSyntax { static { Skript.registerExpression(ExprAttacker.class, Entity.class, ExpressionType.SIMPLE, "[the] (attacker|damager)"); @@ -62,13 +46,15 @@ public class ExprAttacker extends SimpleExpression { @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parser) { - if (!getParser().isCurrentEvent(EntityDamageEvent.class, EntityDeathEvent.class, VehicleDamageEvent.class, VehicleDestroyEvent.class)) { - Skript.error("Cannot use 'attacker' outside of a damage/death/destroy event", ErrorQuality.SEMANTIC_ERROR); - return false; - } return true; } - + + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(EntityDamageEvent.class, EntityDeathEvent.class, + VehicleDamageEvent.class, VehicleDestroyEvent.class); + } + @Override protected Entity[] get(Event e) { return new Entity[] {getAttacker(e)}; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBarterDrops.java b/src/main/java/ch/njol/skript/expressions/ExprBarterDrops.java index e5223893ff5..5203f463c37 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBarterDrops.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBarterDrops.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBarterInput.java b/src/main/java/ch/njol/skript/expressions/ExprBarterInput.java index 1e29861173b..3755054978e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBarterInput.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBarterInput.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBed.java b/src/main/java/ch/njol/skript/expressions/ExprBed.java index cf715b85433..fb01ff66067 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBiome.java b/src/main/java/ch/njol/skript/expressions/ExprBiome.java index b27bdc3e884..29c00deb662 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBiome.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBiome.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBlock.java b/src/main/java/ch/njol/skript/expressions/ExprBlock.java index 6777a3bec9b..6b318f55e95 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBlock.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBlockHardness.java b/src/main/java/ch/njol/skript/expressions/ExprBlockHardness.java index 7d8fb8d0186..74eb4c422a6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBlockHardness.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBlockHardness.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBlockSphere.java b/src/main/java/ch/njol/skript/expressions/ExprBlockSphere.java index a30bc7f9f9a..bce1ce8e435 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBlockSphere.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBlockSphere.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBlocks.java b/src/main/java/ch/njol/skript/expressions/ExprBlocks.java index fbc9683db1e..46122dccbff 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBlocks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBlocks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBookPages.java b/src/main/java/ch/njol/skript/expressions/ExprBookPages.java index a16ad8264ff..d7c28425942 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBookPages.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBookPages.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBookTitle.java b/src/main/java/ch/njol/skript/expressions/ExprBookTitle.java index 5d28bc576e6..c8773550103 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBookTitle.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBookTitle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBreakSpeed.java b/src/main/java/ch/njol/skript/expressions/ExprBreakSpeed.java index a3c5ed36332..82dd4bacd50 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprBreakSpeed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprBreakSpeed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprBurnCookTime.java b/src/main/java/ch/njol/skript/expressions/ExprBurnCookTime.java deleted file mode 100644 index 5445865f858..00000000000 --- a/src/main/java/ch/njol/skript/expressions/ExprBurnCookTime.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ -package ch.njol.skript.expressions; - -import java.util.Arrays; -import java.util.function.Function; - -import ch.njol.skript.classes.Changer.ChangeMode; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.Furnace; -import org.bukkit.event.Event; -import org.bukkit.event.inventory.FurnaceBurnEvent; -import org.jetbrains.annotations.Nullable; - -import ch.njol.skript.Skript; -import ch.njol.skript.aliases.Aliases; -import ch.njol.skript.aliases.ItemType; -import ch.njol.skript.classes.Changer; -import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Examples; -import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.Since; -import ch.njol.skript.expressions.base.PropertyExpression; -import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.ExpressionType; -import ch.njol.skript.lang.SkriptParser; -import ch.njol.skript.util.Timespan; -import ch.njol.util.Kleenean; -import ch.njol.util.coll.CollectionUtils; -import org.skriptlang.skript.lang.arithmetic.Operator; -import org.skriptlang.skript.lang.arithmetic.Arithmetics; - -@Name("Burn/Cook Time") -@Description({ - "The time a furnace takes to burn an item in a fuel burn event.", - "Can also be used to change the burn/cook time of a placed furnace." -}) -@Examples({ - "on fuel burn:", - "\tif fuel slot is coal:", - "\t\tset burning time to 1 tick" -}) -@Since("2.3") -public class ExprBurnCookTime extends PropertyExpression { - - static { - Skript.registerExpression(ExprBurnCookTime.class, Timespan.class, ExpressionType.PROPERTY, - "[the] burn[ing] time", - "[the] (burn|1:cook)[ing] time of %blocks%", - "%blocks%'[s] (burn|1:cook)[ing] time"); - } - - private boolean cookTime; - private boolean isEvent; - - @Override - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { - cookTime = parseResult.mark == 1; - isEvent = matchedPattern == 0; - if (isEvent && !getParser().isCurrentEvent(FurnaceBurnEvent.class)) { - Skript.error("Cannot use 'burning time' outside a fuel burn event."); - return false; - } - if (!isEvent) - setExpr((Expression) exprs[0]); - return true; - } - - @Override - protected Timespan[] get(Event event, Block[] source) { - if (isEvent) { - if (!(event instanceof FurnaceBurnEvent)) - return new Timespan[0]; - return CollectionUtils.array(new Timespan(Timespan.TimePeriod.TICK, ((FurnaceBurnEvent) event).getBurnTime())); - } else { - return Arrays.stream(source) - .map(Block::getState) - .filter(blockState -> blockState instanceof Furnace) - .map(state -> { - Furnace furnace = (Furnace) state; - return new Timespan(Timespan.TimePeriod.TICK, cookTime ? furnace.getCookTime() : furnace.getBurnTime()); - }) - .toArray(Timespan[]::new); - } - } - @Override - @Nullable - public Class[] acceptChange(ChangeMode mode) { - if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.SET) - return CollectionUtils.array(Timespan.class); - return null; - } - - @Override - public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { - if (delta == null) - return; - - Function value = null; - Timespan changed = (Timespan) delta[0]; - - switch (mode) { - case ADD: - value = (original) -> Arithmetics.calculate(Operator.ADDITION, original, changed, Timespan.class); - break; - case REMOVE: - value = (original) -> Arithmetics.difference(original, changed, Timespan.class); - break; - case SET: - value = (original) -> changed; - break; - default: - assert false; - break; - } - - if (isEvent) { - if (!(event instanceof FurnaceBurnEvent)) - return; - - FurnaceBurnEvent burnEvent = (FurnaceBurnEvent) event; - burnEvent.setBurnTime((int) value.apply(new Timespan(Timespan.TimePeriod.TICK, burnEvent.getBurnTime())).getAs(Timespan.TimePeriod.TICK)); - return; - } - - for (Block block : getExpr().getArray(event)) { - BlockState state = block.getState(); - if (!(state instanceof Furnace)) - continue; - Furnace furnace = (Furnace) block.getState(); - long time = value.apply(new Timespan(Timespan.TimePeriod.TICK, cookTime ? furnace.getCookTime() : furnace.getBurnTime())).getAs(Timespan.TimePeriod.TICK); - - if (cookTime) { - furnace.setCookTime((short) time); - } else { - furnace.setBurnTime((short) time); - } - - furnace.update(); - } - } - - @Override - public Class getReturnType() { - return Timespan.class; - } - - @Override - public String toString(@Nullable Event event, boolean debug) { - return isEvent ? "the burning time" : String.format("the %sing time of %s", cookTime ? "cook" : "burn", getExpr().toString(event, debug)); - } - -} diff --git a/src/main/java/ch/njol/skript/expressions/ExprCharacterFromCodepoint.java b/src/main/java/ch/njol/skript/expressions/ExprCharacterFromCodepoint.java index 217ffa6f4f9..485b43b2040 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCharacterFromCodepoint.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCharacterFromCodepoint.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCharacters.java b/src/main/java/ch/njol/skript/expressions/ExprCharacters.java index ea12012dfe5..ba3a8509e5e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCharacters.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCharacters.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCharges.java b/src/main/java/ch/njol/skript/expressions/ExprCharges.java index b13bf99def3..72709b0dde7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCharges.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCharges.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprChatFormat.java b/src/main/java/ch/njol/skript/expressions/ExprChatFormat.java index f9917b0dcb2..99df19b3bd2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprChatFormat.java +++ b/src/main/java/ch/njol/skript/expressions/ExprChatFormat.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.apache.commons.lang.StringUtils; diff --git a/src/main/java/ch/njol/skript/expressions/ExprChatRecipients.java b/src/main/java/ch/njol/skript/expressions/ExprChatRecipients.java index d53c32f0f25..462e518d859 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprChatRecipients.java +++ b/src/main/java/ch/njol/skript/expressions/ExprChatRecipients.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Set; diff --git a/src/main/java/ch/njol/skript/expressions/ExprChestInventory.java b/src/main/java/ch/njol/skript/expressions/ExprChestInventory.java index 241a144ec14..ee1dd7546cb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprChestInventory.java +++ b/src/main/java/ch/njol/skript/expressions/ExprChestInventory.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/expressions/ExprChunk.java b/src/main/java/ch/njol/skript/expressions/ExprChunk.java index 04950b20e36..4131f30bba3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprChunk.java +++ b/src/main/java/ch/njol/skript/expressions/ExprChunk.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/expressions/ExprClicked.java b/src/main/java/ch/njol/skript/expressions/ExprClicked.java index 14a4e4f06c7..536da33b70f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprClicked.java +++ b/src/main/java/ch/njol/skript/expressions/ExprClicked.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.lang.reflect.Array; diff --git a/src/main/java/ch/njol/skript/expressions/ExprClientViewDistance.java b/src/main/java/ch/njol/skript/expressions/ExprClientViewDistance.java index 3d721d2e4fb..ea66c5a0688 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprClientViewDistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprClientViewDistance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCmdCooldownInfo.java b/src/main/java/ch/njol/skript/expressions/ExprCmdCooldownInfo.java index a1904c5fcac..d952105fa22 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCmdCooldownInfo.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCmdCooldownInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.UUID; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCodepoint.java b/src/main/java/ch/njol/skript/expressions/ExprCodepoint.java index a090495f692..a643241e78c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCodepoint.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCodepoint.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprColorOf.java b/src/main/java/ch/njol/skript/expressions/ExprColorOf.java index b1698656dbe..282f7fdb27c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprColorOf.java +++ b/src/main/java/ch/njol/skript/expressions/ExprColorOf.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprColoured.java b/src/main/java/ch/njol/skript/expressions/ExprColoured.java index f681cfb642b..95c1f6a0ebe 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprColoured.java +++ b/src/main/java/ch/njol/skript/expressions/ExprColoured.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCommand.java b/src/main/java/ch/njol/skript/expressions/ExprCommand.java index ef64e6af4cd..8cb71f77e34 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCommand.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCommand.java @@ -1,24 +1,8 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.command.ScriptCommandEvent; +import ch.njol.skript.lang.EventRestrictedSyntax; +import ch.njol.util.coll.CollectionUtils; import org.bukkit.event.Event; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.server.ServerCommandEvent; @@ -49,7 +33,7 @@ "\t\t\tcancel the event"}) @Since("2.0, 2.7 (support for script commands)") @Events("command") -public class ExprCommand extends SimpleExpression { +public class ExprCommand extends SimpleExpression implements EventRestrictedSyntax { static { Skript.registerExpression(ExprCommand.class, String.class, ExpressionType.SIMPLE, @@ -62,13 +46,14 @@ public class ExprCommand extends SimpleExpression { @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - if (!getParser().isCurrentEvent(PlayerCommandPreprocessEvent.class, ServerCommandEvent.class, ScriptCommandEvent.class)) { - Skript.error("The 'command' expression can only be used in a script command or command event"); - return false; - } fullCommand = matchedPattern == 0; return true; } + + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(PlayerCommandPreprocessEvent.class, ServerCommandEvent.class, ScriptCommandEvent.class); + } @Override @Nullable @@ -106,5 +91,5 @@ public Class getReturnType() { public String toString(@Nullable Event e, boolean debug) { return fullCommand ? "the full command" : "the command"; } - + } diff --git a/src/main/java/ch/njol/skript/expressions/ExprCommandInfo.java b/src/main/java/ch/njol/skript/expressions/ExprCommandInfo.java index 6a1184d98ca..8e88a9751b7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCommandInfo.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCommandInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCommandSender.java b/src/main/java/ch/njol/skript/expressions/ExprCommandSender.java index 076a2b8f5cd..2d71a3b2e0e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCommandSender.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCommandSender.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCompassTarget.java b/src/main/java/ch/njol/skript/expressions/ExprCompassTarget.java index 4127b24d140..9bcc06735d4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCompassTarget.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCompassTarget.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCoordinate.java b/src/main/java/ch/njol/skript/expressions/ExprCoordinate.java index dbd1f1ce283..5ae429f3cec 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCoordinate.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCoordinate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java b/src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java index 8df0920a558..53d6b26ae5a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Creeper; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCursorSlot.java b/src/main/java/ch/njol/skript/expressions/ExprCursorSlot.java index 8fdb2573791..0b6580a0d9b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCursorSlot.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCursorSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprCustomModelData.java b/src/main/java/ch/njol/skript/expressions/ExprCustomModelData.java index c05f6d97882..9b04e619f8c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprCustomModelData.java +++ b/src/main/java/ch/njol/skript/expressions/ExprCustomModelData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDamage.java b/src/main/java/ch/njol/skript/expressions/ExprDamage.java index 2d2395bd574..962e20262f2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDamage.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDamage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDamageCause.java b/src/main/java/ch/njol/skript/expressions/ExprDamageCause.java index 9cd8bac4ea3..e8fdbd87d1f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDamageCause.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDamageCause.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDamagedItem.java b/src/main/java/ch/njol/skript/expressions/ExprDamagedItem.java index 8dc3cd995d8..2e7f7a58ad2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDamagedItem.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDamagedItem.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDateAgoLater.java b/src/main/java/ch/njol/skript/expressions/ExprDateAgoLater.java index 177467e9fd6..4d806e2037e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDateAgoLater.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDateAgoLater.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDefaultValue.java b/src/main/java/ch/njol/skript/expressions/ExprDefaultValue.java index 24ccacafad5..336a8376402 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDefaultValue.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDefaultValue.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDifference.java b/src/main/java/ch/njol/skript/expressions/ExprDifference.java index 4e31308e69d..99e55690122 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDifference.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDifference.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDifficulty.java b/src/main/java/ch/njol/skript/expressions/ExprDifficulty.java index 5416cd9a69b..79210ededf5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDifficulty.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDifficulty.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Difficulty; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDirection.java b/src/main/java/ch/njol/skript/expressions/ExprDirection.java index 01596d86ba6..0e64f2f43f8 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDirection.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDirection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDistance.java b/src/main/java/ch/njol/skript/expressions/ExprDistance.java index c9c124be5e4..51d33144ee7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDistance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDrops.java b/src/main/java/ch/njol/skript/expressions/ExprDrops.java index 2528df6c5d0..02809a05502 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDrops.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDrops.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; @@ -26,6 +8,7 @@ import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Name; import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.EventRestrictedSyntax; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -56,7 +39,7 @@ "remove 4 planks from the drops"}) @Since("1.0") @Events("death") -public class ExprDrops extends SimpleExpression { +public class ExprDrops extends SimpleExpression implements EventRestrictedSyntax { static { Skript.registerExpression(ExprDrops.class, ItemType.class, ExpressionType.SIMPLE, "[the] drops"); @@ -66,15 +49,16 @@ public class ExprDrops extends SimpleExpression { @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - if (!getParser().isCurrentEvent(EntityDeathEvent.class, BlockDropItemEvent.class)) { - Skript.error("The expression 'drops' can only be used in death events and block drop events"); - return false; - } if (getParser().isCurrentEvent(EntityDeathEvent.class)) isDeathEvent = true; return true; } + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(EntityDeathEvent.class, BlockDropItemEvent.class); + } + @Override protected ItemType @Nullable [] get(Event event) { if (event instanceof EntityDeathEvent entityDeathEvent) { diff --git a/src/main/java/ch/njol/skript/expressions/ExprDropsOfBlock.java b/src/main/java/ch/njol/skript/expressions/ExprDropsOfBlock.java index 64b5d167927..fd809b73b56 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDropsOfBlock.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDropsOfBlock.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprDurability.java b/src/main/java/ch/njol/skript/expressions/ExprDurability.java index bf8dd737b00..06b176bccdb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprDurability.java +++ b/src/main/java/ch/njol/skript/expressions/ExprDurability.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEgg.java b/src/main/java/ch/njol/skript/expressions/ExprEgg.java index 45f26fd1047..17b18ad73f1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEgg.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEgg.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Egg; diff --git a/src/main/java/ch/njol/skript/expressions/ExprElement.java b/src/main/java/ch/njol/skript/expressions/ExprElement.java index b0d79dd08da..1cad8bddcfd 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprElement.java +++ b/src/main/java/ch/njol/skript/expressions/ExprElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantItem.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantItem.java index 30c9e2036b7..cf06ff046bc 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantItem.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantItem.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantingExpCost.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantingExpCost.java index eafdb5fbe69..4f9a52763dd 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantingExpCost.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantingExpCost.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentBonus.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentBonus.java index f1eadc1de2f..0e599582871 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentBonus.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentBonus.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentLevel.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentLevel.java index 71ccbc01d29..9c4266fb5cf 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentLevel.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentLevel.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOffer.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOffer.java index 284e565d48c..e96f501b1a2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOffer.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOffer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOfferCost.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOfferCost.java index 1b549cc5351..f01d87a476b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOfferCost.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantmentOfferCost.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.enchantments.EnchantmentOffer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnchantments.java b/src/main/java/ch/njol/skript/expressions/ExprEnchantments.java index 054dd99f7b0..8f7f7f409d2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnchantments.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnchantments.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEnderChest.java b/src/main/java/ch/njol/skript/expressions/ExprEnderChest.java index 4eb3c8ccf01..dca7814af51 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEnderChest.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEnderChest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEntities.java b/src/main/java/ch/njol/skript/expressions/ExprEntities.java index 6dabed17cf9..ddbe92d54d1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEntities.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEntities.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEntity.java b/src/main/java/ch/njol/skript/expressions/ExprEntity.java index ec3e45b6d1c..15782c7bcdb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEntity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEntity.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEntityAttribute.java b/src/main/java/ch/njol/skript/expressions/ExprEntityAttribute.java index 5c1ab2f5349..6c672c59ed6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEntityAttribute.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEntityAttribute.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEntityItemUseTime.java b/src/main/java/ch/njol/skript/expressions/ExprEntityItemUseTime.java index 892ea3c7409..31b07d846d6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEntityItemUseTime.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEntityItemUseTime.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEntitySnapshot.java b/src/main/java/ch/njol/skript/expressions/ExprEntitySnapshot.java new file mode 100644 index 00000000000..ab33be08297 --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprEntitySnapshot.java @@ -0,0 +1,71 @@ +package ch.njol.skript.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.*; +import ch.njol.skript.entity.EntityData; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntitySnapshot; +import org.bukkit.entity.FishHook; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +@Name("Entity Snapshot") +@Description({ + "Returns the entity snapshot of a provided entity, which includes all the data associated with it " + + "(name, health, attributes, etc.) at the time this expression is used.", + "Individual attributes of a snapshot cannot be modified or retrieved." +}) +@Examples({ + "spawn a pig at location(0, 0, 0):", + "\tset the max health of entity to 20", + "\tset the health of entity to 20", + "\tset {_snapshot} to the entity snapshot of entity", + "\tclear entity", + "spawn {_snapshot} at location(0, 0, 0)" +}) +@RequiredPlugins("Minecraft 1.20.2+") +@Since("INSERT VERSION") +public class ExprEntitySnapshot extends SimplePropertyExpression { + + static { + if (Skript.classExists("org.bukkit.entity.EntitySnapshot")) + register(ExprEntitySnapshot.class, EntitySnapshot.class, "entity snapshot", "entities/entitydatas"); + } + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + if (Player.class.isAssignableFrom(exprs[0].getReturnType()) || FishHook.class.isAssignableFrom(exprs[0].getReturnType())) { + Skript.error("One or more listed entities can not return an entity snapshot."); + return false; + } + return super.init(exprs, matchedPattern, isDelayed, parseResult); + } + + @Override + public @Nullable EntitySnapshot convert(Object object) { + if (object instanceof Entity entity) { + return entity.createSnapshot(); + } else if (object instanceof EntityData entityData) { + Entity entity = entityData.create(); + EntitySnapshot snapshot = entity.createSnapshot(); + entity.remove(); + return snapshot; + } + return null; + } + + @Override + protected String getPropertyName() { + return "entity snapshot"; + } + + @Override + public Class getReturnType() { + return EntitySnapshot.class; + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprEntityTamer.java b/src/main/java/ch/njol/skript/expressions/ExprEntityTamer.java index 5d5cc0883e7..83f2aa43cc7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEntityTamer.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEntityTamer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEventCancelled.java b/src/main/java/ch/njol/skript/expressions/ExprEventCancelled.java index 59f0059041d..8bdcc466a59 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEventCancelled.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEventCancelled.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Cancellable; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEventExpression.java b/src/main/java/ch/njol/skript/expressions/ExprEventExpression.java index c2f4220be9f..8e08624b7d5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEventExpression.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEventExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEvtInitiator.java b/src/main/java/ch/njol/skript/expressions/ExprEvtInitiator.java index 23a4c4213ce..aa454c71df3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEvtInitiator.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEvtInitiator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprExhaustion.java b/src/main/java/ch/njol/skript/expressions/ExprExhaustion.java index bb607e85f0b..1cab6371c1d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExhaustion.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExhaustion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprExplodedBlocks.java b/src/main/java/ch/njol/skript/expressions/ExprExplodedBlocks.java index aac5d1bd2a3..d67b502f56b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExplodedBlocks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExplodedBlocks.java @@ -1,26 +1,9 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.List; import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.lang.EventRestrictedSyntax; import ch.njol.util.coll.CollectionUtils; import org.bukkit.block.Block; import org.bukkit.event.Event; @@ -61,21 +44,22 @@ "\tadd blocks above event-entity to exploded blocks"}) @Events("explode") @Since("2.5, 2.8.6 (modify blocks)") -public class ExprExplodedBlocks extends SimpleExpression { +public class ExprExplodedBlocks extends SimpleExpression implements EventRestrictedSyntax { static { Skript.registerExpression(ExprExplodedBlocks.class, Block.class, ExpressionType.COMBINED, "[the] exploded blocks"); } - + @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { - if (!getParser().isCurrentEvent(EntityExplodeEvent.class)) { - Skript.error("Exploded blocks can only be retrieved from an explode event."); - return false; - } return true; } - + + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(EntityExplodeEvent.class); + } + @Nullable @Override protected Block[] get(Event e) { diff --git a/src/main/java/ch/njol/skript/expressions/ExprExplosionBlockYield.java b/src/main/java/ch/njol/skript/expressions/ExprExplosionBlockYield.java index a2a03b7f636..d38b373cfb3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExplosionBlockYield.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExplosionBlockYield.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java b/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java index aaefbc86f44..78605dbef38 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExplosionYield.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java b/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java index f89c1daef1d..72f70126894 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java +++ b/src/main/java/ch/njol/skript/expressions/ExprExplosiveYield.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Creeper; diff --git a/src/main/java/ch/njol/skript/expressions/ExprEyeLocation.java b/src/main/java/ch/njol/skript/expressions/ExprEyeLocation.java index 268148b21ad..bd4249c3f9d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprEyeLocation.java +++ b/src/main/java/ch/njol/skript/expressions/ExprEyeLocation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFacing.java b/src/main/java/ch/njol/skript/expressions/ExprFacing.java index 6b754154362..ec9b073d8df 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFacing.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFacing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFallDistance.java b/src/main/java/ch/njol/skript/expressions/ExprFallDistance.java index 34f5a00b0a5..161fa4dfe1d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFallDistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFallDistance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFertilizedBlocks.java b/src/main/java/ch/njol/skript/expressions/ExprFertilizedBlocks.java index 78e28775b12..9c8cc950ab0 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFertilizedBlocks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFertilizedBlocks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFilter.java b/src/main/java/ch/njol/skript/expressions/ExprFilter.java index 738fb1c9ea9..e4e38a35ee7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFilter.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFilter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFinalDamage.java b/src/main/java/ch/njol/skript/expressions/ExprFinalDamage.java index 6d5573527e0..324ded1aef7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFinalDamage.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFinalDamage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFireTicks.java b/src/main/java/ch/njol/skript/expressions/ExprFireTicks.java index 5dd6370b39e..47ec212e2af 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFireTicks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFireTicks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; @@ -56,14 +38,12 @@ public boolean init(Expression[] expressions, int matchedPattern, Kleenean is } @Override - @Nullable - public Timespan convert(Entity entity) { + public @Nullable Timespan convert(Entity entity) { return new Timespan(TimePeriod.TICK, (max ? entity.getMaxFireTicks() : Math.max(entity.getFireTicks(), 0))); } @Override - @Nullable - public Class[] acceptChange(ChangeMode mode) { + public Class @Nullable [] acceptChange(ChangeMode mode) { if (max) return null; return switch (mode) { @@ -95,7 +75,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { } @Override - public Class getReturnType() { + public Class getReturnType() { return Timespan.class; } diff --git a/src/main/java/ch/njol/skript/expressions/ExprFlightMode.java b/src/main/java/ch/njol/skript/expressions/ExprFlightMode.java index 861ae7c4dbe..c25e0040d74 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFlightMode.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFlightMode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFoodLevel.java b/src/main/java/ch/njol/skript/expressions/ExprFoodLevel.java index 8f749ef1358..c2a13217e45 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFoodLevel.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFoodLevel.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFormatDate.java b/src/main/java/ch/njol/skript/expressions/ExprFormatDate.java index 63a755cdd29..06bd926d034 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFormatDate.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFormatDate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.text.SimpleDateFormat; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFreezeTicks.java b/src/main/java/ch/njol/skript/expressions/ExprFreezeTicks.java index 11588c466a3..c75766f09ea 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprFreezeTicks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprFreezeTicks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprFurnaceSlot.java b/src/main/java/ch/njol/skript/expressions/ExprFurnaceSlot.java deleted file mode 100644 index b43652b7ae4..00000000000 --- a/src/main/java/ch/njol/skript/expressions/ExprFurnaceSlot.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ -package ch.njol.skript.expressions; - -import ch.njol.skript.Skript; -import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Events; -import ch.njol.skript.doc.Examples; -import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.Since; -import ch.njol.skript.effects.Delay; -import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.ExpressionType; -import ch.njol.skript.lang.SkriptParser.ParseResult; -import ch.njol.skript.lang.util.SimpleExpression; -import ch.njol.skript.registrations.EventValues; -import ch.njol.skript.util.slot.InventorySlot; -import ch.njol.skript.util.slot.Slot; -import ch.njol.util.Kleenean; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.Furnace; -import org.bukkit.event.Event; -import org.bukkit.event.inventory.FurnaceBurnEvent; -import org.bukkit.event.inventory.FurnaceSmeltEvent; -import org.bukkit.inventory.FurnaceInventory; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -@Name("Furnace Slot") -@Description({ - "A slot of a furnace, i.e. either the ore, fuel or result slot.", - "Remember to use 'block' and not furnace, as furnace is not an existing expression.", - "Note that the result and the result slot refer to separate things. the result is the product in a smelt event " + - "and the result slot is the output slot of a furnace (where the result will end up).", - "Note that if the result in a smelt event is changed to an item that differs in type from the items currently in " + - "the result slot, the smelting will fail to complete (the item will attempt to smelt itself again).", - "Note that if values other than the result are changed, event values may not accurately reflect the actual items in a furnace.", - "Thus you may wish to use the event block in this case (e.g. the fuel slot of the event-block) to get accurate values if needed." -}) -@Examples({ - "set the fuel slot of the clicked block to a lava bucket", - "set the block's ore slot to 64 iron ore", - "give the result of the block to the player", - "clear the result slot of the block" -}) -@Events({"smelt", "fuel burn"}) -@Since("1.0, 2.8.0 (syntax rework)") -public class ExprFurnaceSlot extends SimpleExpression { - - private static final int ORE = 0, FUEL = 1, RESULT = 2; - - static { - Skript.registerExpression(ExprFurnaceSlot.class, Slot.class, ExpressionType.PROPERTY, - "[the] (0:ore slot|1:fuel slot|2:result [5:slot])", - "[the] (0:ore|1:fuel|2:result) slot[s] of %blocks%", - "%blocks%'[s] (0:ore|1:fuel|2:result) slot[s]" - ); - } - - @Nullable - private Expression blocks; - private boolean isEvent; - private boolean isResultSlot; - private int slot; - - @Override - @SuppressWarnings("unchecked") - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - isEvent = matchedPattern == 0; - if (!isEvent) - blocks = (Expression) exprs[0]; - - slot = parseResult.mark; - isResultSlot = slot == 7; - if (isResultSlot) - slot = RESULT; - - if (isEvent && (slot == ORE || slot == RESULT) && !getParser().isCurrentEvent(FurnaceSmeltEvent.class)) { - Skript.error("Cannot use 'result slot' or 'ore slot' outside an ore smelt event."); - return false; - } else if (isEvent && slot == FUEL && !getParser().isCurrentEvent(FurnaceBurnEvent.class)) { - Skript.error("Cannot use 'fuel slot' outside a fuel burn event."); - return false; - } - - return true; - } - - @Override - @Nullable - protected Slot[] get(Event event) { - Block[] blocks; - if (isEvent) { - blocks = new Block[1]; - if (event instanceof FurnaceSmeltEvent) { - blocks[0] = ((FurnaceSmeltEvent) event).getBlock(); - } else if (event instanceof FurnaceBurnEvent) { - blocks[0] = ((FurnaceBurnEvent) event).getBlock(); - } else { - return new Slot[0]; - } - } else { - assert this.blocks != null; - blocks = this.blocks.getArray(event); - } - - List slots = new ArrayList<>(); - for (Block block : blocks) { - BlockState state = block.getState(); - if (!(state instanceof Furnace)) - continue; - FurnaceInventory furnaceInventory = ((Furnace) state).getInventory(); - if (isEvent && !Delay.isDelayed(event)) { - slots.add(new FurnaceEventSlot(event, furnaceInventory)); - } else { // Normal inventory slot is fine since the time will always be in the present - slots.add(new InventorySlot(furnaceInventory, slot)); - } - } - return slots.toArray(new Slot[0]); - } - - @Override - public boolean isSingle() { - if (isEvent) - return true; - assert blocks != null; - return blocks.isSingle(); - } - - @Override - public Class getReturnType() { - return InventorySlot.class; - } - - @Override - public String toString(@Nullable Event event, boolean debug) { - String time = (getTime() == -1) ? "past " : (getTime() == 1) ? "future " : ""; - String slotName = (slot == ORE) ? "ore" : (slot == FUEL) ? "fuel" : "result"; - if (isEvent) { - return "the " + time + slotName + (isResultSlot ? " slot" : ""); - } else { - assert blocks != null; - return "the " + time + slotName + " slot of " + blocks.toString(event, debug); - } - } - - @Override - public boolean setTime(int time) { - if (isEvent) { // getExpr will be null - if (slot == RESULT && !isResultSlot) { // 'the past/future result' - doesn't make sense, don't allow it - return false; - } else if (slot == FUEL) { - return setTime(time, FurnaceBurnEvent.class); - } else { - return setTime(time, FurnaceSmeltEvent.class); - } - } - return false; - } - - private final class FurnaceEventSlot extends InventorySlot { - - private final Event event; - - public FurnaceEventSlot(Event event, FurnaceInventory furnaceInventory) { - super(furnaceInventory, slot); - this.event = event; - } - - @Override - @Nullable - public ItemStack getItem() { - switch (slot) { - case ORE: - if (event instanceof FurnaceSmeltEvent) { - ItemStack source = ((FurnaceSmeltEvent) event).getSource().clone(); - if (getTime() != EventValues.TIME_FUTURE) - return source; - source.setAmount(source.getAmount() - 1); - return source; - } - return super.getItem(); - case FUEL: - if (event instanceof FurnaceBurnEvent) { - ItemStack fuel = ((FurnaceBurnEvent) event).getFuel().clone(); - if (getTime() != EventValues.TIME_FUTURE) - return fuel; - // a single lava bucket becomes an empty bucket - // see https://minecraft.wiki/w/Smelting#Fuel - // this is declared here because setting the amount to 0 may cause the ItemStack to become AIR - Material newMaterial = fuel.getType() == Material.LAVA_BUCKET ? Material.BUCKET : Material.AIR; - fuel.setAmount(fuel.getAmount() - 1); - if (fuel.getAmount() == 0) - fuel = new ItemStack(newMaterial); - return fuel; - } - return super.getItem(); - case RESULT: - if (event instanceof FurnaceSmeltEvent) { - ItemStack result = ((FurnaceSmeltEvent) event).getResult().clone(); - if (isResultSlot) { // Special handling for getting the result slot - ItemStack currentResult = ((FurnaceInventory) getInventory()).getResult(); - if (currentResult != null) - currentResult = currentResult.clone(); - if (getTime() != EventValues.TIME_FUTURE) { // 'past result slot' and 'result slot' - return currentResult; - } else if (currentResult != null && currentResult.isSimilar(result)) { // 'future result slot' - currentResult.setAmount(currentResult.getAmount() + result.getAmount()); - return currentResult; - } else { - return result; - } - } - // 'the result' - return result; - } - return super.getItem(); - } - return null; - } - - @Override - public void setItem(@Nullable ItemStack item) { - if (slot == RESULT && !isResultSlot && event instanceof FurnaceSmeltEvent) { - ((FurnaceSmeltEvent) event).setResult(item != null ? item : new ItemStack(Material.AIR)); - } else { - if (getTime() == EventValues.TIME_FUTURE) { // Since this is a future expression, run it AFTER the event - Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), () -> FurnaceEventSlot.super.setItem(item)); - } else { - super.setItem(item); - } - } - } - - } - -} diff --git a/src/main/java/ch/njol/skript/expressions/ExprGameMode.java b/src/main/java/ch/njol/skript/expressions/ExprGameMode.java index 6d3107c04b7..4d299078307 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprGameMode.java +++ b/src/main/java/ch/njol/skript/expressions/ExprGameMode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprGameRule.java b/src/main/java/ch/njol/skript/expressions/ExprGameRule.java index 5c59a39c30e..7e21a7caa2a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprGameRule.java +++ b/src/main/java/ch/njol/skript/expressions/ExprGameRule.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.GameRule; diff --git a/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java b/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java index ede9345a61b..b616707c6e4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java +++ b/src/main/java/ch/njol/skript/expressions/ExprGlidingState.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprGlowing.java b/src/main/java/ch/njol/skript/expressions/ExprGlowing.java index ea3f7b4f2ce..d6cbb3e1d82 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprGlowing.java +++ b/src/main/java/ch/njol/skript/expressions/ExprGlowing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprGravity.java b/src/main/java/ch/njol/skript/expressions/ExprGravity.java index 01d99ea1f0a..fdc07803b15 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprGravity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprGravity.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHanging.java b/src/main/java/ch/njol/skript/expressions/ExprHanging.java index e18f97fbdd7..0d746617fca 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHanging.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHanging.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHash.java b/src/main/java/ch/njol/skript/expressions/ExprHash.java index fed5b62d6b1..7614220f014 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHash.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHash.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.nio.charset.Charset; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHatchingNumber.java b/src/main/java/ch/njol/skript/expressions/ExprHatchingNumber.java index 95c3ef3cc0c..49228742570 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHatchingNumber.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHatchingNumber.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHatchingType.java b/src/main/java/ch/njol/skript/expressions/ExprHatchingType.java index ebf470f4c75..c5b8639657c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHatchingType.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHatchingType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHealAmount.java b/src/main/java/ch/njol/skript/expressions/ExprHealAmount.java index 2facfc74f2c..5410d2ccc5d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHealAmount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHealAmount.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHealReason.java b/src/main/java/ch/njol/skript/expressions/ExprHealReason.java index 330ec4ed4d7..bc6602eb8b3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHealReason.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHealReason.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHealth.java b/src/main/java/ch/njol/skript/expressions/ExprHealth.java index e33b85a47b1..5d04ed1a9ca 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHealth.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHealth.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHostname.java b/src/main/java/ch/njol/skript/expressions/ExprHostname.java index 08d1bfda582..3c6230f3d3a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHostname.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHostname.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHotbarButton.java b/src/main/java/ch/njol/skript/expressions/ExprHotbarButton.java index 847f2353009..823d56abcac 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHotbarButton.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHotbarButton.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHotbarSlot.java b/src/main/java/ch/njol/skript/expressions/ExprHotbarSlot.java index 174560bdfae..80e8fc645f5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHotbarSlot.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHotbarSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprHumidity.java b/src/main/java/ch/njol/skript/expressions/ExprHumidity.java index 68562c7b27a..6dd9f54c256 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprHumidity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprHumidity.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprIP.java b/src/main/java/ch/njol/skript/expressions/ExprIP.java index 632ee8d6c84..6c8136d7a2c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprIP.java +++ b/src/main/java/ch/njol/skript/expressions/ExprIP.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.net.InetAddress; diff --git a/src/main/java/ch/njol/skript/expressions/ExprIndexOf.java b/src/main/java/ch/njol/skript/expressions/ExprIndexOf.java index b8b5e51bf60..94d27f52c79 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprIndexOf.java +++ b/src/main/java/ch/njol/skript/expressions/ExprIndexOf.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprIndices.java b/src/main/java/ch/njol/skript/expressions/ExprIndices.java index c48380e1ece..ea8cb405e54 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprIndices.java +++ b/src/main/java/ch/njol/skript/expressions/ExprIndices.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprInput.java b/src/main/java/ch/njol/skript/expressions/ExprInput.java index a417efcdd51..c7e9e2adcf7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprInput.java +++ b/src/main/java/ch/njol/skript/expressions/ExprInput.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprInventory.java b/src/main/java/ch/njol/skript/expressions/ExprInventory.java index 60e930ddf66..702f2411332 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprInventory.java +++ b/src/main/java/ch/njol/skript/expressions/ExprInventory.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/expressions/ExprInventoryAction.java b/src/main/java/ch/njol/skript/expressions/ExprInventoryAction.java index 6b46f610f70..3a8c24a88cd 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprInventoryAction.java +++ b/src/main/java/ch/njol/skript/expressions/ExprInventoryAction.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.inventory.InventoryAction; diff --git a/src/main/java/ch/njol/skript/expressions/ExprInventoryCloseReason.java b/src/main/java/ch/njol/skript/expressions/ExprInventoryCloseReason.java index 136c27bebfb..41191362b22 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprInventoryCloseReason.java +++ b/src/main/java/ch/njol/skript/expressions/ExprInventoryCloseReason.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprInventoryInfo.java b/src/main/java/ch/njol/skript/expressions/ExprInventoryInfo.java index a5e1b34e455..c7dc5c8395f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprInventoryInfo.java +++ b/src/main/java/ch/njol/skript/expressions/ExprInventoryInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprInventorySlot.java b/src/main/java/ch/njol/skript/expressions/ExprInventorySlot.java index a60bc899a7b..4a3fc3618e7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprInventorySlot.java +++ b/src/main/java/ch/njol/skript/expressions/ExprInventorySlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprItem.java b/src/main/java/ch/njol/skript/expressions/ExprItem.java index c7f2f8a97cd..5b51d868f26 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprItem.java +++ b/src/main/java/ch/njol/skript/expressions/ExprItem.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Item; diff --git a/src/main/java/ch/njol/skript/expressions/ExprItemAmount.java b/src/main/java/ch/njol/skript/expressions/ExprItemAmount.java index 046d4ec41c9..be39645cd7f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprItemAmount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprItemAmount.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.aliases.ItemType; @@ -110,6 +92,6 @@ public Class getReturnType() { @Override protected String getPropertyName() { - return "item[[ ]stack] (amount|size|number)"; + return "item amount"; } } diff --git a/src/main/java/ch/njol/skript/expressions/ExprItemCooldown.java b/src/main/java/ch/njol/skript/expressions/ExprItemCooldown.java index 74dcee55cbb..162884af692 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprItemCooldown.java +++ b/src/main/java/ch/njol/skript/expressions/ExprItemCooldown.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprItemWithCustomModelData.java b/src/main/java/ch/njol/skript/expressions/ExprItemWithCustomModelData.java index 643b038c29f..b2818ebb807 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprItemWithCustomModelData.java +++ b/src/main/java/ch/njol/skript/expressions/ExprItemWithCustomModelData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprItemWithEnchantmentGlint.java b/src/main/java/ch/njol/skript/expressions/ExprItemWithEnchantmentGlint.java new file mode 100644 index 00000000000..cb4c158f19e --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprItemWithEnchantmentGlint.java @@ -0,0 +1,62 @@ +package ch.njol.skript.expressions; + +import org.bukkit.event.Event; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.Nullable; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.doc.*; +import ch.njol.skript.expressions.base.PropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; + +@Name("Item with Enchantment Glint") +@Description("Get an item with or without enchantment glint.") +@Examples({ + "set {_item with glint} to diamond with enchantment glint", + "set {_item without glint} to diamond without enchantment glint" +}) +@RequiredPlugins("Spigot 1.20.5+") +@Since("INSERT VERSION") +public class ExprItemWithEnchantmentGlint extends PropertyExpression { + + static { + if (Skript.methodExists(ItemMeta.class, "getEnchantmentGlintOverride")) + Skript.registerExpression(ExprItemWithEnchantmentGlint.class, ItemType.class, ExpressionType.PROPERTY, "%itemtypes% with[:out] [enchant[ment]] glint"); + } + + private boolean glint; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + setExpr((Expression) expressions[0]); + glint = !parseResult.hasTag("out"); + return true; + } + + @Override + protected ItemType[] get(Event event, ItemType[] source) { + return get(source, itemType -> { + itemType = itemType.clone(); + ItemMeta meta = itemType.getItemMeta(); + meta.setEnchantmentGlintOverride(glint); + itemType.setItemMeta(meta); + return itemType; + }); + } + + @Override + public Class getReturnType() { + return ItemType.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return getExpr().toString(event, debug) + (glint ? " with" : " without") + " enchantment glint"; + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprItemWithLore.java b/src/main/java/ch/njol/skript/expressions/ExprItemWithLore.java index 31df444794e..636e5ab8134 100755 --- a/src/main/java/ch/njol/skript/expressions/ExprItemWithLore.java +++ b/src/main/java/ch/njol/skript/expressions/ExprItemWithLore.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/expressions/ExprItemsIn.java b/src/main/java/ch/njol/skript/expressions/ExprItemsIn.java index 9e76e01ed7a..4f24751430e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprItemsIn.java +++ b/src/main/java/ch/njol/skript/expressions/ExprItemsIn.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLanguage.java b/src/main/java/ch/njol/skript/expressions/ExprLanguage.java index 8410c88230a..401f0757936 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLanguage.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLanguage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastAttacker.java b/src/main/java/ch/njol/skript/expressions/ExprLastAttacker.java index 5c601412c01..7ff00b01eb5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastAttacker.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastAttacker.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastColor.java b/src/main/java/ch/njol/skript/expressions/ExprLastColor.java index 0de147257c0..4a1ff6c2b27 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastColor.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastColor.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastDamage.java b/src/main/java/ch/njol/skript/expressions/ExprLastDamage.java index ede427b156f..29fa9e87a4f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastDamage.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastDamage.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastDamageCause.java b/src/main/java/ch/njol/skript/expressions/ExprLastDamageCause.java index c6c571745cf..4510b989ac7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastDamageCause.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastDamageCause.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.bukkitutil.HealthUtils; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastLoadedServerIcon.java b/src/main/java/ch/njol/skript/expressions/ExprLastLoadedServerIcon.java index 351e8d7ba7b..c8be04c1eae 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastLoadedServerIcon.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastLoadedServerIcon.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastLoginTime.java b/src/main/java/ch/njol/skript/expressions/ExprLastLoginTime.java index 365ccaf83b0..25ab2ba82fc 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastLoginTime.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastLoginTime.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastResourcePackResponse.java b/src/main/java/ch/njol/skript/expressions/ExprLastResourcePackResponse.java index 9359539afef..bcaad2b5bfa 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastResourcePackResponse.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastResourcePackResponse.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLastSpawnedEntity.java b/src/main/java/ch/njol/skript/expressions/ExprLastSpawnedEntity.java index fc762672b11..3135c3d22fe 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLastSpawnedEntity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLastSpawnedEntity.java @@ -1,28 +1,10 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.lang.reflect.Array; import ch.njol.skript.effects.EffFireworkLaunch; +import ch.njol.skript.sections.EffSecShoot; import ch.njol.skript.sections.EffSecSpawn; -import ch.njol.util.coll.CollectionUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.Firework; import org.bukkit.entity.Item; @@ -37,7 +19,6 @@ import ch.njol.skript.doc.Since; import ch.njol.skript.effects.EffDrop; import ch.njol.skript.effects.EffLightning; -import ch.njol.skript.effects.EffShoot; import ch.njol.skript.entity.EntityData; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; @@ -100,7 +81,7 @@ protected Entity[] get(Event event) { en = EffSecSpawn.lastSpawned; break; case 1: - en = EffShoot.lastSpawned; + en = EffSecShoot.lastSpawned; break; case 2: en = EffDrop.lastSpawned; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLeashHolder.java b/src/main/java/ch/njol/skript/expressions/ExprLeashHolder.java index 7a0db57d46b..7e223c2e3f7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLeashHolder.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLeashHolder.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLength.java b/src/main/java/ch/njol/skript/expressions/ExprLength.java index f41ec0ec0d6..1b9e4641769 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLength.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLength.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLevel.java b/src/main/java/ch/njol/skript/expressions/ExprLevel.java index baa5f110a36..b3273130b75 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLevel.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLevel.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLevelProgress.java b/src/main/java/ch/njol/skript/expressions/ExprLevelProgress.java index c39e3b24c2a..7c682609082 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLevelProgress.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLevelProgress.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLightLevel.java b/src/main/java/ch/njol/skript/expressions/ExprLightLevel.java index 69d24f7a9c0..4cd45e781fa 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLightLevel.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLightLevel.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLocation.java b/src/main/java/ch/njol/skript/expressions/ExprLocation.java index 99c197db734..c4a61f0f58c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLocation.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLocation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLocationAt.java b/src/main/java/ch/njol/skript/expressions/ExprLocationAt.java index 3b77c8ef61a..a39d3181efa 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLocationAt.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLocationAt.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLocationFromVector.java b/src/main/java/ch/njol/skript/expressions/ExprLocationFromVector.java index 92aa68c0b4a..d4c2b0545ef 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLocationFromVector.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLocationFromVector.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLocationOf.java b/src/main/java/ch/njol/skript/expressions/ExprLocationOf.java index ec460da961d..04a2050fbec 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLocationOf.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLocationOf.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java b/src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java index 84d1b90e9e2..1526165ecd7 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLoopIteration.java b/src/main/java/ch/njol/skript/expressions/ExprLoopIteration.java index fcee1e58f73..19c889ef00d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLoopIteration.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLoopIteration.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLore.java b/src/main/java/ch/njol/skript/expressions/ExprLore.java index 30a0dbf2188..7b4c26361cf 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLore.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLore.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprLowestHighestSolidBlock.java b/src/main/java/ch/njol/skript/expressions/ExprLowestHighestSolidBlock.java index a43f67d5026..599c142606b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLowestHighestSolidBlock.java +++ b/src/main/java/ch/njol/skript/expressions/ExprLowestHighestSolidBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMOTD.java b/src/main/java/ch/njol/skript/expressions/ExprMOTD.java index bf99a755d80..34e570c1d31 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMOTD.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMOTD.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMaxDurability.java b/src/main/java/ch/njol/skript/expressions/ExprMaxDurability.java index 1287a8647f2..ba9359fb1a4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMaxDurability.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMaxDurability.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMaxFreezeTicks.java b/src/main/java/ch/njol/skript/expressions/ExprMaxFreezeTicks.java index 13c72a32f61..cc0bda4172f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMaxFreezeTicks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMaxFreezeTicks.java @@ -1,22 +1,4 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMaxHealth.java b/src/main/java/ch/njol/skript/expressions/ExprMaxHealth.java index cf796aedcbf..cfe64906bf0 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMaxHealth.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMaxHealth.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMaxItemUseTime.java b/src/main/java/ch/njol/skript/expressions/ExprMaxItemUseTime.java index 66e5466d696..9eb30a0da0e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMaxItemUseTime.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMaxItemUseTime.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMaxMinecartSpeed.java b/src/main/java/ch/njol/skript/expressions/ExprMaxMinecartSpeed.java index be6bf4e5112..27b8bf6e774 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMaxMinecartSpeed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMaxMinecartSpeed.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMaxPlayers.java b/src/main/java/ch/njol/skript/expressions/ExprMaxPlayers.java index 9f497ad3d07..50c2bf5762f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMaxPlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMaxPlayers.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMe.java b/src/main/java/ch/njol/skript/expressions/ExprMe.java index 112259e4f2f..a365c38bea6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMe.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMe.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMemory.java b/src/main/java/ch/njol/skript/expressions/ExprMemory.java index 1ea10604b74..391ef7d73ce 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMemory.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMemory.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Locale; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMendingRepairAmount.java b/src/main/java/ch/njol/skript/expressions/ExprMendingRepairAmount.java index b2e2e40169b..39368c412ec 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMendingRepairAmount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMendingRepairAmount.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMiddleOfLocation.java b/src/main/java/ch/njol/skript/expressions/ExprMiddleOfLocation.java index 7f72db5c2ea..8e605106e46 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMiddleOfLocation.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMiddleOfLocation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMinecartDerailedFlyingVelocity.java b/src/main/java/ch/njol/skript/expressions/ExprMinecartDerailedFlyingVelocity.java index ba15473acc3..f109a65dc6f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMinecartDerailedFlyingVelocity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMinecartDerailedFlyingVelocity.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprMoonPhase.java b/src/main/java/ch/njol/skript/expressions/ExprMoonPhase.java index 7fbe876571e..68211c6fe98 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprMoonPhase.java +++ b/src/main/java/ch/njol/skript/expressions/ExprMoonPhase.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprName.java b/src/main/java/ch/njol/skript/expressions/ExprName.java index fd43791f4aa..ae6b295e670 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprName.java +++ b/src/main/java/ch/njol/skript/expressions/ExprName.java @@ -1,34 +1,17 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; import java.util.List; import ch.njol.skript.bukkitutil.InventoryUtils; -import ch.njol.skript.bukkitutil.ItemUtils; +import ch.njol.skript.lang.util.common.AnyNamed; import org.bukkit.Bukkit; import org.bukkit.GameRule; import org.bukkit.Nameable; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.block.BlockState; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LivingEntity; @@ -117,17 +100,16 @@ public class ExprName extends SimplePropertyExpression { @Nullable private static BungeeComponentSerializer serializer; - static final boolean HAS_GAMERULES; static { // Check for Adventure API if (Skript.classExists("net.kyori.adventure.text.Component") && Skript.methodExists(Bukkit.class, "createInventory", InventoryHolder.class, int.class, Component.class)) serializer = BungeeComponentSerializer.get(); - HAS_GAMERULES = Skript.classExists("org.bukkit.GameRule"); - register(ExprName.class, String.class, "(1¦name[s]|2¦(display|nick|chat|custom)[ ]name[s])", "offlineplayers/entities/blocks/itemtypes/inventories/slots/worlds" - + (HAS_GAMERULES ? "/gamerules" : "")); - register(ExprName.class, String.class, "(3¦(player|tab)[ ]list name[s])", "players"); + register(ExprName.class, String.class, "(1:name[s])", "offlineplayers/entities/inventories/named"); + register(ExprName.class, String.class, "(2:(display|nick|chat|custom)[ ]name[s])", "offlineplayers/entities/inventories/named"); + register(ExprName.class, String.class, "(3:(player|tab)[ ]list name[s])", "players"); + // we keep the entity input because we want to do something special with entities } /* @@ -141,54 +123,36 @@ public class ExprName extends SimplePropertyExpression { public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { mark = parseResult.mark; setExpr(exprs[0]); - if (mark != 1 && World.class.isAssignableFrom(getExpr().getReturnType())) { - Skript.error("Can't use 'display name' with worlds. Use 'name' instead."); - return false; - } return true; } @Override - @Nullable - public String convert(Object object) { - if (object instanceof OfflinePlayer && ((OfflinePlayer) object).isOnline()) - object = ((OfflinePlayer) object).getPlayer(); - - if (object instanceof Player) { - switch (mark) { - case 1: - return ((Player) object).getName(); - case 2: - return ((Player) object).getDisplayName(); - case 3: - return ((Player) object).getPlayerListName(); + public @Nullable String convert(Object object) { + if (object instanceof OfflinePlayer offlinePlayer) { + if (offlinePlayer.isOnline()) { // Defer to player check below + object = offlinePlayer.getPlayer(); + } else { // We can only support "name" + return mark == 1 ? offlinePlayer.getName() : null; } - } else if (object instanceof OfflinePlayer) { - return mark == 1 ? ((OfflinePlayer) object).getName() : null; - } else if (object instanceof Entity) { - return ((Entity) object).getCustomName(); - } else if (object instanceof Block) { - BlockState state = ((Block) object).getState(); - if (state instanceof Nameable) - return ((Nameable) state).getCustomName(); - } else if (object instanceof ItemType) { - ItemMeta m = ((ItemType) object).getItemMeta(); - return m.hasDisplayName() ? m.getDisplayName() : null; - } else if (object instanceof Inventory) { - Inventory inventory = (Inventory) object; + } + + if (object instanceof Player player) { + return switch (mark) { + case 1 -> player.getName(); + case 2 -> player.getDisplayName(); + case 3 -> player.getPlayerListName(); + default -> throw new IllegalStateException("Unexpected value: " + mark); + }; + } else if (object instanceof Nameable nameable) { + if (mark == 1 && nameable instanceof CommandSender sender) + return sender.getName(); + return nameable.getCustomName(); + } else if (object instanceof Inventory inventory) { if (inventory.getViewers().isEmpty()) return null; return InventoryUtils.getTitle(inventory.getViewers().get(0).getOpenInventory()); - } else if (object instanceof Slot) { - ItemStack is = ((Slot) object).getItem(); - if (is != null && is.hasItemMeta()) { - ItemMeta m = is.getItemMeta(); - return m.hasDisplayName() ? m.getDisplayName() : null; - } - } else if (object instanceof World) { - return ((World) object).getName(); - } else if (HAS_GAMERULES && object instanceof GameRule) { - return ((GameRule) object).getName(); + } else if (object instanceof AnyNamed named) { + return named.name(); } return null; } @@ -214,41 +178,32 @@ public Class[] acceptChange(ChangeMode mode) { public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { String name = delta != null ? (String) delta[0] : null; for (Object object : getExpr().getArray(event)) { - if (object instanceof Player) { + if (object instanceof Player player) { switch (mark) { case 2: - ((Player) object).setDisplayName(name != null ? name + ChatColor.RESET : ((Player) object).getName()); + player.setDisplayName(name != null ? name + ChatColor.RESET : ((Player) object).getName()); break; case 3: // Null check not necessary. This method will use the player's name if 'name' is null. - ((Player) object).setPlayerListName(name); + player.setPlayerListName(name); break; } - } else if (object instanceof Entity) { - ((Entity) object).setCustomName(name); + } else if (object instanceof Entity entity) { + entity.setCustomName(name); if (mark == 2 || mode == ChangeMode.RESET) // Using "display name" - ((Entity) object).setCustomNameVisible(name != null); - if (object instanceof LivingEntity) - ((LivingEntity) object).setRemoveWhenFarAway(name == null); - } else if (object instanceof Block) { - BlockState state = ((Block) object).getState(); - if (state instanceof Nameable) { - ((Nameable) state).setCustomName(name); - state.update(); - } - } else if (object instanceof ItemType) { - ItemType i = (ItemType) object; - ItemMeta m = i.getItemMeta(); - m.setDisplayName(name); - i.setItemMeta(m); - } else if (object instanceof Inventory) { - Inventory inv = (Inventory) object; - - if (inv.getViewers().isEmpty()) + entity.setCustomNameVisible(name != null); + if (object instanceof LivingEntity living) + living.setRemoveWhenFarAway(name == null); + } else if (object instanceof AnyNamed named) { + if (named.supportsNameChange()) + named.setName(name); + } else if (object instanceof Inventory inventory) { + + if (inventory.getViewers().isEmpty()) return; // Create a clone to avoid a ConcurrentModificationException - List viewers = new ArrayList<>(inv.getViewers()); + List viewers = new ArrayList<>(inventory.getViewers()); - InventoryType type = inv.getType(); + InventoryType type = inventory.getType(); if (!type.isCreatable()) return; @@ -257,9 +212,9 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { if (name == null) name = type.getDefaultTitle(); if (type == InventoryType.CHEST) { - copy = Bukkit.createInventory(inv.getHolder(), inv.getSize(), name); + copy = Bukkit.createInventory(inventory.getHolder(), inventory.getSize(), name); } else { - copy = Bukkit.createInventory(inv.getHolder(), type, name); + copy = Bukkit.createInventory(inventory.getHolder(), type, name); } } else { Component component = type.defaultTitle(); @@ -268,22 +223,13 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { component = serializer.deserialize(components); } if (type == InventoryType.CHEST) { - copy = Bukkit.createInventory(inv.getHolder(), inv.getSize(), component); + copy = Bukkit.createInventory(inventory.getHolder(), inventory.getSize(), component); } else { - copy = Bukkit.createInventory(inv.getHolder(), type, component); + copy = Bukkit.createInventory(inventory.getHolder(), type, component); } } - copy.setContents(inv.getContents()); + copy.setContents(inventory.getContents()); viewers.forEach(viewer -> viewer.openInventory(copy)); - } else if (object instanceof Slot) { - Slot s = (Slot) object; - ItemStack is = s.getItem(); - if (is != null && !ItemUtils.isAir(is.getType())) { - ItemMeta m = is.hasItemMeta() ? is.getItemMeta() : Bukkit.getItemFactory().getItemMeta(is.getType()); - m.setDisplayName(name); - is.setItemMeta(m); - s.setItem(is); - } } } } @@ -295,12 +241,11 @@ public Class getReturnType() { @Override protected String getPropertyName() { - switch (mark) { - case 1: return "name"; - case 2: return "display name"; - case 3: return "tablist name"; - default: return "name"; - } + return switch (mark) { + case 2 -> "display name"; + case 3 -> "tablist name"; + default -> "name"; + }; } } diff --git a/src/main/java/ch/njol/skript/expressions/ExprNamed.java b/src/main/java/ch/njol/skript/expressions/ExprNamed.java index 483560d7c46..dd00ab15490 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNamed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNamed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.lang.Literal; diff --git a/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java b/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java index a06c3b886a8..3f5db26c97a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java b/src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java index bdf0aaf8036..1dd1fe22733 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprNow.java b/src/main/java/ch/njol/skript/expressions/ExprNow.java index 546bc9afb07..fc1e12739d5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNow.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNow.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprNumberOfCharacters.java b/src/main/java/ch/njol/skript/expressions/ExprNumberOfCharacters.java index 300a4e1f0bb..b394ef51162 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNumberOfCharacters.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNumberOfCharacters.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprNumbers.java b/src/main/java/ch/njol/skript/expressions/ExprNumbers.java index 570f0405186..140be747f76 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNumbers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNumbers.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprOfflinePlayers.java b/src/main/java/ch/njol/skript/expressions/ExprOfflinePlayers.java index 585b09ff59e..d4a6f50c9b4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOfflinePlayers.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOfflinePlayers.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java index d79907e760a..42a29b7e4cf 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOnlinePlayersCount.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprOpenedInventory.java b/src/main/java/ch/njol/skript/expressions/ExprOpenedInventory.java index 2b17f75a423..3531ad88cb3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOpenedInventory.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOpenedInventory.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.bukkitutil.InventoryUtils; diff --git a/src/main/java/ch/njol/skript/expressions/ExprOps.java b/src/main/java/ch/njol/skript/expressions/ExprOps.java index 440a341c682..554bf84544d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprOps.java +++ b/src/main/java/ch/njol/skript/expressions/ExprOps.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprParse.java b/src/main/java/ch/njol/skript/expressions/ExprParse.java index b212f6a2660..d1da502924c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprParse.java +++ b/src/main/java/ch/njol/skript/expressions/ExprParse.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprParseError.java b/src/main/java/ch/njol/skript/expressions/ExprParseError.java index 9b24bad4971..16607ccb64d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprParseError.java +++ b/src/main/java/ch/njol/skript/expressions/ExprParseError.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPassenger.java b/src/main/java/ch/njol/skript/expressions/ExprPassenger.java index 50673f8c928..1be2b7d4c39 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPassenger.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPassenger.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPercent.java b/src/main/java/ch/njol/skript/expressions/ExprPercent.java index 985932fbaff..8ab15321af5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPercent.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPercent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPermissions.java b/src/main/java/ch/njol/skript/expressions/ExprPermissions.java index 78bc0a96881..36a54f620ab 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPermissions.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPermissions.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPickupDelay.java b/src/main/java/ch/njol/skript/expressions/ExprPickupDelay.java index 5c06e18166e..98c41a54599 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPickupDelay.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPickupDelay.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPing.java b/src/main/java/ch/njol/skript/expressions/ExprPing.java index f09cdce45d9..855e435a05a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPing.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPlain.java b/src/main/java/ch/njol/skript/expressions/ExprPlain.java index 1b6c367496c..3ff04713e9a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPlain.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPlain.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPlayerProtocolVersion.java b/src/main/java/ch/njol/skript/expressions/ExprPlayerProtocolVersion.java index e64946919d2..0e2561bb7b6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPlayerProtocolVersion.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPlayerProtocolVersion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPlayerViewDistance.java b/src/main/java/ch/njol/skript/expressions/ExprPlayerViewDistance.java index b912ec9df27..03389e13c80 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPlayerViewDistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPlayerViewDistance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPlayerWeather.java b/src/main/java/ch/njol/skript/expressions/ExprPlayerWeather.java index 3febd9fe2b4..5cb17f56877 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPlayerWeather.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPlayerWeather.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPlayerlistHeaderFooter.java b/src/main/java/ch/njol/skript/expressions/ExprPlayerlistHeaderFooter.java index 17902858012..03dc81ba00b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPlayerlistHeaderFooter.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPlayerlistHeaderFooter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPlugins.java b/src/main/java/ch/njol/skript/expressions/ExprPlugins.java index b38e0dd7593..6c6b4924e0e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPlugins.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPlugins.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPortal.java b/src/main/java/ch/njol/skript/expressions/ExprPortal.java index cbc03323789..a3c3011febe 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPortal.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPortal.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPortalCooldown.java b/src/main/java/ch/njol/skript/expressions/ExprPortalCooldown.java index 830152c0c00..09762d8f437 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPortalCooldown.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPortalCooldown.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPotionEffect.java b/src/main/java/ch/njol/skript/expressions/ExprPotionEffect.java index c8939bb6754..e067d7d0c52 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPotionEffect.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPotionEffect.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPotionEffectTier.java b/src/main/java/ch/njol/skript/expressions/ExprPotionEffectTier.java index ceef6bb07bb..42158ac6bb2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPotionEffectTier.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPotionEffectTier.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPotionEffects.java b/src/main/java/ch/njol/skript/expressions/ExprPotionEffects.java index 671296ecb48..89b66f570fa 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPotionEffects.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPotionEffects.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprProjectileCriticalState.java b/src/main/java/ch/njol/skript/expressions/ExprProjectileCriticalState.java index 93eab3cdb27..51f194c997b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprProjectileCriticalState.java +++ b/src/main/java/ch/njol/skript/expressions/ExprProjectileCriticalState.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.AbstractArrow; diff --git a/src/main/java/ch/njol/skript/expressions/ExprProtocolVersion.java b/src/main/java/ch/njol/skript/expressions/ExprProtocolVersion.java index 2bcd0130f67..f2fb55d0dd1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprProtocolVersion.java +++ b/src/main/java/ch/njol/skript/expressions/ExprProtocolVersion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprPushedBlocks.java b/src/main/java/ch/njol/skript/expressions/ExprPushedBlocks.java index a26ee0e00db..bdb6bb5a6bb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprPushedBlocks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprPushedBlocks.java @@ -1,23 +1,6 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; +import ch.njol.skript.lang.EventRestrictedSyntax; import ch.njol.util.coll.CollectionUtils; import org.bukkit.block.Block; import org.bukkit.event.Event; @@ -41,7 +24,7 @@ @Description("Blocks which are moved in a piston event. Cannot be used outside of piston events.") @Examples("the moved blocks") @Since("2.2-dev27") -public class ExprPushedBlocks extends SimpleExpression { +public class ExprPushedBlocks extends SimpleExpression implements EventRestrictedSyntax { static { Skript.registerExpression(ExprPushedBlocks.class, Block.class, ExpressionType.SIMPLE, "[the] moved blocks"); @@ -49,14 +32,14 @@ public class ExprPushedBlocks extends SimpleExpression { @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - if (!getParser().isCurrentEvent(BlockPistonExtendEvent.class, BlockPistonRetractEvent.class)) { - Skript.error("The moved blocks are only usable in piston extend and retract events", ErrorQuality.SEMANTIC_ERROR); - return false; - } - return true; } - + + @Override + public Class[] supportedEvents() { + return CollectionUtils.array(BlockPistonExtendEvent.class, BlockPistonRetractEvent.class); + } + @Override @Nullable protected Block[] get(Event e) { diff --git a/src/main/java/ch/njol/skript/expressions/ExprQuitReason.java b/src/main/java/ch/njol/skript/expressions/ExprQuitReason.java index 7f702758aa0..878cf26bcf9 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprQuitReason.java +++ b/src/main/java/ch/njol/skript/expressions/ExprQuitReason.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.player.PlayerQuitEvent.QuitReason; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRandom.java b/src/main/java/ch/njol/skript/expressions/ExprRandom.java index bce326b39e6..16db494d587 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRandom.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRandom.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.lang.reflect.Array; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRandomCharacter.java b/src/main/java/ch/njol/skript/expressions/ExprRandomCharacter.java index 7a808da2c4a..00d1ca08f87 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRandomCharacter.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRandomCharacter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRandomNumber.java b/src/main/java/ch/njol/skript/expressions/ExprRandomNumber.java index f9ae82447fd..1826296ef90 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRandomNumber.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRandomNumber.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRandomUUID.java b/src/main/java/ch/njol/skript/expressions/ExprRandomUUID.java index 38433a81e8e..8a75a30e5ad 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRandomUUID.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRandomUUID.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.UUID; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRawName.java b/src/main/java/ch/njol/skript/expressions/ExprRawName.java index 232410445ea..fec8a2d54b6 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRawName.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRawName.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRawString.java b/src/main/java/ch/njol/skript/expressions/ExprRawString.java index abd9f4ac097..13bdf4075b2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRawString.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRawString.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprReadiedArrow.java b/src/main/java/ch/njol/skript/expressions/ExprReadiedArrow.java index 61c7386d587..47a122dee40 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprReadiedArrow.java +++ b/src/main/java/ch/njol/skript/expressions/ExprReadiedArrow.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRedstoneBlockPower.java b/src/main/java/ch/njol/skript/expressions/ExprRedstoneBlockPower.java index b056f4c53b8..4e6538dbff1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRedstoneBlockPower.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRedstoneBlockPower.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.block.Block; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRepeat.java b/src/main/java/ch/njol/skript/expressions/ExprRepeat.java index 6ec93cd2671..65b3f974dbe 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRepeat.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRepeat.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprResonatingTime.java b/src/main/java/ch/njol/skript/expressions/ExprResonatingTime.java index ef4067dfd46..55a527ee286 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprResonatingTime.java +++ b/src/main/java/ch/njol/skript/expressions/ExprResonatingTime.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRespawnLocation.java b/src/main/java/ch/njol/skript/expressions/ExprRespawnLocation.java index 1e31cc19afd..f90fc8e9ac9 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRespawnLocation.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRespawnLocation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprReversedList.java b/src/main/java/ch/njol/skript/expressions/ExprReversedList.java index 2a99e1eecfe..b1fd4639cb1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprReversedList.java +++ b/src/main/java/ch/njol/skript/expressions/ExprReversedList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRingingTime.java b/src/main/java/ch/njol/skript/expressions/ExprRingingTime.java index a86c925b701..7fe43c41476 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRingingTime.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRingingTime.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprRound.java b/src/main/java/ch/njol/skript/expressions/ExprRound.java index b7cefbf5c04..5907bd47381 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRound.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRound.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSaturation.java b/src/main/java/ch/njol/skript/expressions/ExprSaturation.java index c9486c567fb..c5eb5a9a1f4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSaturation.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSaturation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java b/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java index 80490af39e3..37782e9a0b5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java +++ b/src/main/java/ch/njol/skript/expressions/ExprScoreboardTags.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Set; diff --git a/src/main/java/ch/njol/skript/expressions/ExprScript.java b/src/main/java/ch/njol/skript/expressions/ExprScript.java index 7c14d7146eb..7ba8f9b078f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprScript.java +++ b/src/main/java/ch/njol/skript/expressions/ExprScript.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprScripts.java b/src/main/java/ch/njol/skript/expressions/ExprScripts.java index 862948da7da..c25d7a3384c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprScripts.java +++ b/src/main/java/ch/njol/skript/expressions/ExprScripts.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSeaLevel.java b/src/main/java/ch/njol/skript/expressions/ExprSeaLevel.java index 216c6cd81a1..87a94b98c18 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSeaLevel.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSeaLevel.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.World; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSeaPickles.java b/src/main/java/ch/njol/skript/expressions/ExprSeaPickles.java index a58e6cbbca3..414fa84878b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSeaPickles.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSeaPickles.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSeed.java b/src/main/java/ch/njol/skript/expressions/ExprSeed.java index cb260863fe8..1a48935f080 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSeed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSeed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.World; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSentCommands.java b/src/main/java/ch/njol/skript/expressions/ExprSentCommands.java index b4ece43c86c..3e6c3f4cebd 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSentCommands.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSentCommands.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprServerIcon.java b/src/main/java/ch/njol/skript/expressions/ExprServerIcon.java index d51a3f8c439..a6baaecacc5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprServerIcon.java +++ b/src/main/java/ch/njol/skript/expressions/ExprServerIcon.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSets.java b/src/main/java/ch/njol/skript/expressions/ExprSets.java index a49b589b875..318475a390f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSets.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSets.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/expressions/ExprShooter.java b/src/main/java/ch/njol/skript/expressions/ExprShooter.java index 98111d7b7f8..48da301d59a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprShooter.java +++ b/src/main/java/ch/njol/skript/expressions/ExprShooter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; @@ -28,6 +10,7 @@ import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.sections.EffSecShoot; import ch.njol.util.Kleenean; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; @@ -46,42 +29,46 @@ public class ExprShooter extends PropertyExpression { static { Skript.registerExpression(ExprShooter.class, LivingEntity.class, ExpressionType.SIMPLE, "[the] shooter [of %projectile%]"); } - - @SuppressWarnings({"unchecked", "null"}) + @Override - public boolean init(final Expression[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) { + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + //noinspection unchecked setExpr((Expression) exprs[0]); return true; } @Override - protected LivingEntity[] get(final Event e, final Projectile[] source) { + protected LivingEntity @Nullable [] get(Event event, Projectile[] source) { + if (event instanceof EffSecShoot.ShootEvent shootEvent && getExpr().isDefault() && !(shootEvent.getProjectile() instanceof Projectile)) { + return new LivingEntity[]{shootEvent.getShooter()}; + } + return get(source, projectile -> { Object shooter = projectile != null ? projectile.getShooter() : null; - if (shooter instanceof LivingEntity) - return (LivingEntity) shooter; + if (shooter instanceof LivingEntity livingShooter) + return livingShooter; return null; }); } @Override - @Nullable - public Class[] acceptChange(final ChangeMode mode) { + public @Nullable Class[] acceptChange(ChangeMode mode) { if (mode == ChangeMode.SET) return new Class[] {LivingEntity.class}; return super.acceptChange(mode); } @Override - public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) { + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { if (mode == ChangeMode.SET) { assert delta != null; - for (final Projectile p : getExpr().getArray(e)) { - assert p != null : getExpr(); - p.setShooter((ProjectileSource) delta[0]); + ProjectileSource source = (ProjectileSource) delta[0]; + for (Projectile projectile : getExpr().getArray(event)) { + assert projectile != null : getExpr(); + projectile.setShooter(source); } } else { - super.change(e, delta, mode); + super.change(event, delta, mode); } } @@ -91,8 +78,8 @@ public Class getReturnType() { } @Override - public String toString(final @Nullable Event e, final boolean debug) { - return "the shooter" + (getExpr().isDefault() ? "" : " of " + getExpr().toString(e, debug)); + public String toString(@Nullable Event event, boolean debug) { + return "the shooter" + (getExpr().isDefault() ? "" : " of " + getExpr().toString(event, debug)); } } diff --git a/src/main/java/ch/njol/skript/expressions/ExprShuffledList.java b/src/main/java/ch/njol/skript/expressions/ExprShuffledList.java index 5329dcb7210..342640bbb30 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprShuffledList.java +++ b/src/main/java/ch/njol/skript/expressions/ExprShuffledList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSignText.java b/src/main/java/ch/njol/skript/expressions/ExprSignText.java index b35fc88b7c5..eb5403025a4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSignText.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSignText.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.bukkitutil.ItemUtils; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSlotIndex.java b/src/main/java/ch/njol/skript/expressions/ExprSlotIndex.java index 005d31ed4e1..0acbc9d27e4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSlotIndex.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSlotIndex.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSortedList.java b/src/main/java/ch/njol/skript/expressions/ExprSortedList.java index c1ffda82f46..93c7acab71b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSortedList.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSortedList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSourceBlock.java b/src/main/java/ch/njol/skript/expressions/ExprSourceBlock.java index b75edb252a2..5d71744f476 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSourceBlock.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSourceBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSpawn.java b/src/main/java/ch/njol/skript/expressions/ExprSpawn.java index cf77fd9a714..b60ba5f4afb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSpawn.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSpawn.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSpawnEggEntity.java b/src/main/java/ch/njol/skript/expressions/ExprSpawnEggEntity.java new file mode 100644 index 00000000000..db177912ff6 --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprSpawnEggEntity.java @@ -0,0 +1,106 @@ +package ch.njol.skript.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.bukkitutil.ItemUtils; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.*; +import ch.njol.skript.entity.EntityData; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.skript.util.slot.Slot; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntitySnapshot; +import org.bukkit.event.Event; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SpawnEggMeta; +import org.jetbrains.annotations.Nullable; + +@Name("Spawn Egg Entity") +@Description({ + "Gets or sets the entity snapshot that the provided spawn eggs will spawn when used." +}) +@Examples({ + "set {_item} to a zombie spawn egg", + "broadcast the spawn egg entity of {_item}", + "", + "spawn a pig at location(0,0,0):", + "\tset the max health of entity to 20", + "\tset the health of entity to 20", + "\tset {_snapshot} to the entity snapshot of entity", + "\tclear entity", + "set the spawn egg entity of {_item} to {_snapshot}", + "if the spawn egg entity of {_item} is {_snapshot}: # Minecraft 1.20.5+", + "", + "set the spawn egg entity of {_item} to (random element out of all entities)", + "", + "set the spawn egg entity of {_item} to a zombie" +}) +@RequiredPlugins("Minecraft 1.20.2+, Minecraft 1.20.5+ (comparisons)") +@Since("INSERT VERSION") +public class ExprSpawnEggEntity extends SimplePropertyExpression { + + static { + if (Skript.classExists("org.bukkit.entity.EntitySnapshot")) + register(ExprSpawnEggEntity.class, EntitySnapshot.class, "spawn egg entity", "itemstacks/itemtypes/slots"); + } + + @Override + public @Nullable EntitySnapshot convert(Object object) { + ItemStack itemStack = ItemUtils.asItemStack(object); + if (itemStack == null || !(itemStack.getItemMeta() instanceof SpawnEggMeta eggMeta)) + return null; + return eggMeta.getSpawnedEntity(); + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (mode == ChangeMode.SET) + return CollectionUtils.array(EntitySnapshot.class, Entity.class, EntityData.class); + return null; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (delta == null) + return; + EntitySnapshot snapshot = null; + if (delta[0] instanceof EntitySnapshot entitySnapshot) { + snapshot = entitySnapshot; + } else if (delta[0] instanceof Entity entity) { + snapshot = entity.createSnapshot(); + } else if (delta[0] instanceof EntityData entityData) { + Entity entity = entityData.create(); + snapshot = entity.createSnapshot(); + entity.remove(); + } + if (snapshot == null) + return; + + for (Object object : getExpr().getArray(event)) { + ItemStack item = ItemUtils.asItemStack(object); + if (item == null || !(item.getItemMeta() instanceof SpawnEggMeta eggMeta)) + continue; + eggMeta.setSpawnedEntity(snapshot); + if (object instanceof Slot slot) { + item.setItemMeta(eggMeta); + slot.setItem(item); + } else if (object instanceof ItemType itemType) { + itemType.setItemMeta(eggMeta); + } else if (object instanceof ItemStack itemStack) { + itemStack.setItemMeta(eggMeta); + } + } + } + + @Override + public Class getReturnType() { + return EntitySnapshot.class; + } + + @Override + protected String getPropertyName() { + return "spawn egg entity"; + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprSpawnReason.java b/src/main/java/ch/njol/skript/expressions/ExprSpawnReason.java index b4b2d8378e4..7f3fccd055a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSpawnReason.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSpawnReason.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSpecialNumber.java b/src/main/java/ch/njol/skript/expressions/ExprSpecialNumber.java index cfe8d9204d1..c1bc0db108b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSpecialNumber.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSpecialNumber.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSpectatorTarget.java b/src/main/java/ch/njol/skript/expressions/ExprSpectatorTarget.java index 0bd663bd4f2..e04fbef630e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSpectatorTarget.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSpectatorTarget.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSpeed.java b/src/main/java/ch/njol/skript/expressions/ExprSpeed.java index 310a7212bf3..c98659184de 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSpeed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSpeed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprStringCase.java b/src/main/java/ch/njol/skript/expressions/ExprStringCase.java index c92fee8648a..7632aae0e75 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprStringCase.java +++ b/src/main/java/ch/njol/skript/expressions/ExprStringCase.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.apache.commons.lang.WordUtils; diff --git a/src/main/java/ch/njol/skript/expressions/ExprSubstring.java b/src/main/java/ch/njol/skript/expressions/ExprSubstring.java index f3b7ed3e66b..fffc6561ab5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprSubstring.java +++ b/src/main/java/ch/njol/skript/expressions/ExprSubstring.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTPS.java b/src/main/java/ch/njol/skript/expressions/ExprTPS.java index 99e0a3ce64c..7268c02e9f3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTPS.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTPS.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTamer.java b/src/main/java/ch/njol/skript/expressions/ExprTamer.java index a4e1ce667ea..01746157346 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTamer.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTamer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTarget.java b/src/main/java/ch/njol/skript/expressions/ExprTarget.java index 26e4a38596a..6f320192891 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTarget.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTarget.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.function.Predicate; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTargetedBlock.java b/src/main/java/ch/njol/skript/expressions/ExprTargetedBlock.java index e9320c055ff..ee1c6aeacd3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTargetedBlock.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTargetedBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTeleportCause.java b/src/main/java/ch/njol/skript/expressions/ExprTeleportCause.java index 537ad9d0707..66dc05d69ee 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTeleportCause.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTeleportCause.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTemperature.java b/src/main/java/ch/njol/skript/expressions/ExprTemperature.java index 80231e0201c..60f00d1c269 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTemperature.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTemperature.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTernary.java b/src/main/java/ch/njol/skript/expressions/ExprTernary.java index 8faaa0c72f7..8fa2fa71258 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTernary.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTernary.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTimePlayed.java b/src/main/java/ch/njol/skript/expressions/ExprTimePlayed.java index c1a861e98ba..c78e842d667 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTimePlayed.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTimePlayed.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTimes.java b/src/main/java/ch/njol/skript/expressions/ExprTimes.java index 16d4de265d5..b8b6c8dcd34 100755 --- a/src/main/java/ch/njol/skript/expressions/ExprTimes.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTimes.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTimespanDetails.java b/src/main/java/ch/njol/skript/expressions/ExprTimespanDetails.java index 7f3800e5d4e..6bafc7c1301 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTimespanDetails.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTimespanDetails.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTool.java b/src/main/java/ch/njol/skript/expressions/ExprTool.java index ec66d6e5654..6abe96bfb1c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTool.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTool.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTotalExperience.java b/src/main/java/ch/njol/skript/expressions/ExprTotalExperience.java index 52b201ab53a..fd851d7d6aa 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTotalExperience.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTotalExperience.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.bukkitutil.PlayerUtils; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTransformReason.java b/src/main/java/ch/njol/skript/expressions/ExprTransformReason.java index b21e48d5085..7f8fc391150 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTransformReason.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTransformReason.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprTypeOf.java b/src/main/java/ch/njol/skript/expressions/ExprTypeOf.java index 4b15464534b..0d17ed9e90a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprTypeOf.java +++ b/src/main/java/ch/njol/skript/expressions/ExprTypeOf.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/expressions/ExprUUID.java b/src/main/java/ch/njol/skript/expressions/ExprUUID.java index 42912a72a86..4f0a0022a26 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprUUID.java +++ b/src/main/java/ch/njol/skript/expressions/ExprUUID.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/ch/njol/skript/expressions/ExprUnbreakable.java b/src/main/java/ch/njol/skript/expressions/ExprUnbreakable.java index bda14bb13a0..8795130c8bb 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprUnbreakable.java +++ b/src/main/java/ch/njol/skript/expressions/ExprUnbreakable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprUnixDate.java b/src/main/java/ch/njol/skript/expressions/ExprUnixDate.java index 160c45d0ea4..be0c74743b9 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprUnixDate.java +++ b/src/main/java/ch/njol/skript/expressions/ExprUnixDate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/expressions/ExprUnixTicks.java b/src/main/java/ch/njol/skript/expressions/ExprUnixTicks.java index 205e8a1ac7e..3eb3bab7632 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprUnixTicks.java +++ b/src/main/java/ch/njol/skript/expressions/ExprUnixTicks.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/expressions/ExprValue.java b/src/main/java/ch/njol/skript/expressions/ExprValue.java index 6e331dfccb9..83d561352e3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprValue.java +++ b/src/main/java/ch/njol/skript/expressions/ExprValue.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.lang.reflect.Array; diff --git a/src/main/java/ch/njol/skript/expressions/ExprValueWithin.java b/src/main/java/ch/njol/skript/expressions/ExprValueWithin.java index ba4283f9aa6..3e5e898b38c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprValueWithin.java +++ b/src/main/java/ch/njol/skript/expressions/ExprValueWithin.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorAngleBetween.java b/src/main/java/ch/njol/skript/expressions/ExprVectorAngleBetween.java index 420b8a742e9..c23630d00a1 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorAngleBetween.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorAngleBetween.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorBetweenLocations.java b/src/main/java/ch/njol/skript/expressions/ExprVectorBetweenLocations.java index 8770cd342c8..fbc7b37165d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorBetweenLocations.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorBetweenLocations.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorCrossProduct.java b/src/main/java/ch/njol/skript/expressions/ExprVectorCrossProduct.java index 267af53382b..03f7f70b148 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorCrossProduct.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorCrossProduct.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorCylindrical.java b/src/main/java/ch/njol/skript/expressions/ExprVectorCylindrical.java index c349b907669..476d785bec2 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorCylindrical.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorCylindrical.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorDotProduct.java b/src/main/java/ch/njol/skript/expressions/ExprVectorDotProduct.java index cdc9d78b2b6..b4a860b0d63 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorDotProduct.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorDotProduct.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorFromDirection.java b/src/main/java/ch/njol/skript/expressions/ExprVectorFromDirection.java index e458b54bbf9..7c02614f8aa 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorFromDirection.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorFromDirection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorFromXYZ.java b/src/main/java/ch/njol/skript/expressions/ExprVectorFromXYZ.java index 51686f096d4..cfc5d67de21 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorFromXYZ.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorFromXYZ.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorFromYawAndPitch.java b/src/main/java/ch/njol/skript/expressions/ExprVectorFromYawAndPitch.java index 139e7b50638..f98cb52838e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorFromYawAndPitch.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorFromYawAndPitch.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorLength.java b/src/main/java/ch/njol/skript/expressions/ExprVectorLength.java index 62e5696e098..f16cb3b060a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorLength.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorLength.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorNormalize.java b/src/main/java/ch/njol/skript/expressions/ExprVectorNormalize.java index 98fe029f88a..27bf04842ed 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorNormalize.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorNormalize.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.util.VectorMath; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorOfLocation.java b/src/main/java/ch/njol/skript/expressions/ExprVectorOfLocation.java index 9c4697a4135..ccb29c5386f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorOfLocation.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorOfLocation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorProjection.java b/src/main/java/ch/njol/skript/expressions/ExprVectorProjection.java index 8e1378e5ab3..7fff00f8846 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorProjection.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorProjection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorRandom.java b/src/main/java/ch/njol/skript/expressions/ExprVectorRandom.java index 458b33a31da..fe8bbd9380a 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorRandom.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorRandom.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorSpherical.java b/src/main/java/ch/njol/skript/expressions/ExprVectorSpherical.java index 881d36a532b..cf19b65d047 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorSpherical.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorSpherical.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVectorSquaredLength.java b/src/main/java/ch/njol/skript/expressions/ExprVectorSquaredLength.java index bdfeeb33b74..3812f910bd8 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVectorSquaredLength.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVectorSquaredLength.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.util.Vector; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVehicle.java b/src/main/java/ch/njol/skript/expressions/ExprVehicle.java index db27bffa076..b45da85eedd 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVehicle.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVehicle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVelocity.java b/src/main/java/ch/njol/skript/expressions/ExprVelocity.java index 9292f2ed30c..3cea900ab22 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVelocity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVelocity.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.entity.Entity; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVersion.java b/src/main/java/ch/njol/skript/expressions/ExprVersion.java index 27793fbdf36..9c28e31b989 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVersion.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVersion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVersionString.java b/src/main/java/ch/njol/skript/expressions/ExprVersionString.java index 32427bc0747..407dfec0d0b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprVersionString.java +++ b/src/main/java/ch/njol/skript/expressions/ExprVersionString.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprVillagerLevel.java b/src/main/java/ch/njol/skript/expressions/ExprVillagerLevel.java new file mode 100644 index 00000000000..5878d82f868 --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprVillagerLevel.java @@ -0,0 +1,120 @@ +package ch.njol.skript.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser; +import ch.njol.util.Kleenean; +import ch.njol.util.Math2; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Villager; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +@Name("Villager Level/Experience") +@Description({ + "Represents the level/experience of a villager.", + "The level will determine which trades are available to players (value between 1 and 5, defaults to 1).", + "When a villager's level is 1, they may lose their profession if they don't have a workstation.", + "Experience works along with the leveling system, determining which level the villager will move to.", + "Experience must be greater than or equal to 0.", + "Learn more about villager levels on Minecraft Wiki" +}) +@Examples({ + "set {_level} to villager level of {_villager}", + "set villager level of last spawned villager to 2", + "add 1 to villager level of target entity", + "remove 1 from villager level of event-entity", + "reset villager level of event-entity", + "set villager experience of last spawned entity to 100" +}) +@Since("INSERT VERSION") +public class ExprVillagerLevel extends SimplePropertyExpression { + + private static final boolean HAS_INCREASE_METHOD = Skript.methodExists(Villager.class, "increaseLevel", int.class); + + static { + register(ExprVillagerLevel.class, Number.class, "villager (level|:experience)", "livingentities"); + } + + private boolean experience; + + @Override + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + this.experience = parseResult.hasTag("experience"); + return super.init(expressions, matchedPattern, isDelayed, parseResult); + } + + @Override + public @Nullable Number convert(LivingEntity from) { + if (from instanceof Villager villager) + return experience ? villager.getVillagerExperience() : villager.getVillagerLevel(); + return null; + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + return switch (mode) { + case SET, ADD, REMOVE, RESET -> CollectionUtils.array(Number.class); + default -> null; + }; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + Number number = delta != null && delta[0] instanceof Number num ? num : 1; + int changeValue = number.intValue(); + + for (LivingEntity livingEntity : getExpr().getArray(event)) { + if (!(livingEntity instanceof Villager villager)) continue; + + int minLevel; + int maxLevel; + int previousAmount; + if (experience) { + minLevel = 0; + maxLevel = Integer.MAX_VALUE; + previousAmount = villager.getVillagerExperience(); + } else { + minLevel = 1; + maxLevel = 5; + previousAmount = villager.getVillagerLevel(); + } + int newLevel = switch (mode) { + case SET -> changeValue; + case ADD -> previousAmount + changeValue; + case REMOVE -> previousAmount - changeValue; + default -> minLevel; + }; + newLevel = Math2.fit(minLevel, newLevel, maxLevel); + if (experience) { + villager.setVillagerExperience(newLevel); + } else if (newLevel > previousAmount && HAS_INCREASE_METHOD) { + int increase = Math2.fit(minLevel, newLevel - previousAmount, maxLevel); + // According to the docs for this method: + // Increases the level of this villager. + // The villager will also unlock new recipes unlike the raw 'setVillagerLevel' method + villager.increaseLevel(increase); + } else { + villager.setVillagerLevel(newLevel); + } + } + } + + @Override + protected String getPropertyName() { + return "villager " + (experience ? "experience" : "level"); + } + + @Override + public Class getReturnType() { + return Number.class; + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprVillagerProfession.java b/src/main/java/ch/njol/skript/expressions/ExprVillagerProfession.java new file mode 100644 index 00000000000..65eb4bc7827 --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprVillagerProfession.java @@ -0,0 +1,66 @@ +package ch.njol.skript.expressions; + +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +@Name("Villager Profession") +@Description("Represents the profession of a villager.") +@Examples({ + "set {_p} to villager profession of event-entity", + "villager profession of event-entity = nitwit profession", + "set villager profession of {_villager} to librarian profession", + "delete villager profession of event-entity" +}) +@Since("INSERT VERSION") +public class ExprVillagerProfession extends SimplePropertyExpression { + + static { + register(ExprVillagerProfession.class, Profession.class, "villager profession", "livingentities"); + } + + @Override + public @Nullable Profession convert(LivingEntity from) { + if (from instanceof Villager villager) + return villager.getProfession(); + return null; + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + return switch (mode) { + case SET, DELETE -> CollectionUtils.array(Profession.class); + default -> null; + }; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + Profession profession = delta != null && delta[0] instanceof Profession pro ? pro : Profession.NONE; + + for (LivingEntity livingEntity : getExpr().getArray(event)) { + if (livingEntity instanceof Villager villager) + villager.setProfession(profession); + } + } + + @Override + protected String getPropertyName() { + return "villager profession"; + } + + @Override + public Class getReturnType() { + return Profession.class; + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprVillagerType.java b/src/main/java/ch/njol/skript/expressions/ExprVillagerType.java new file mode 100644 index 00000000000..f29da4972ba --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprVillagerType.java @@ -0,0 +1,66 @@ +package ch.njol.skript.expressions; + +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Type; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +@Name("Villager Type") +@Description("Represents the type of a villager. This usually represents the biome the villager is from.") +@Examples({ + "set {_type} to villager type of {_villager}", + "villager type of {_villager} = plains", + "set villager type of event-entity to plains" +}) +@Since("INSERT VERSION") +public class ExprVillagerType extends SimplePropertyExpression { + + static { + register(ExprVillagerType.class, Type.class, "villager type", "livingentities"); + } + + @Override + public @Nullable Type convert(LivingEntity from) { + if (from instanceof Villager villager) + return villager.getVillagerType(); + return null; + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (mode == ChangeMode.SET) + return CollectionUtils.array(Type.class); + return null; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + Type type = delta != null && delta[0] instanceof Type t ? t : null; + if (type == null) + return; + + for (LivingEntity livingEntity : getExpr().getArray(event)) { + if (livingEntity instanceof Villager villager) + villager.setVillagerType(type); + } + } + + @Override + protected String getPropertyName() { + return "villager type"; + } + + @Override + public Class getReturnType() { + return Type.class; + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprWeather.java b/src/main/java/ch/njol/skript/expressions/ExprWeather.java index 7c332d7fc0e..7f9a3551559 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWeather.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWeather.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.World; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWhether.java b/src/main/java/ch/njol/skript/expressions/ExprWhether.java index 1b4050f0068..823042bbae3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWhether.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWhether.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWhitelist.java b/src/main/java/ch/njol/skript/expressions/ExprWhitelist.java index e14334a4a3e..355070c268f 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWhitelist.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWhitelist.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.effects.EffEnforceWhitelist; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index 5c257a68e86..1c57ba189dc 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWorld.java b/src/main/java/ch/njol/skript/expressions/ExprWorld.java index dd1fa865b77..90cfc779697 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWorld.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWorld.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Chunk; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWorldEnvironment.java b/src/main/java/ch/njol/skript/expressions/ExprWorldEnvironment.java index c713b8d9e62..ce0635a217b 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWorldEnvironment.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWorldEnvironment.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWorldFromName.java b/src/main/java/ch/njol/skript/expressions/ExprWorldFromName.java index c99b1a27903..436498f4c91 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWorldFromName.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWorldFromName.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprWorlds.java b/src/main/java/ch/njol/skript/expressions/ExprWorlds.java index b33b5f65eda..d067294a374 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWorlds.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWorlds.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/expressions/ExprXOf.java b/src/main/java/ch/njol/skript/expressions/ExprXOf.java index 04dc49c8971..00fd8fe63d3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprXOf.java +++ b/src/main/java/ch/njol/skript/expressions/ExprXOf.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/ExprYawPitch.java b/src/main/java/ch/njol/skript/expressions/ExprYawPitch.java index 65dffb4f600..0ec30f2048c 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprYawPitch.java +++ b/src/main/java/ch/njol/skript/expressions/ExprYawPitch.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.ServerPlatform; diff --git a/src/main/java/ch/njol/skript/expressions/LitAt.java b/src/main/java/ch/njol/skript/expressions/LitAt.java index f26b1db7143..fba2b58b59c 100644 --- a/src/main/java/ch/njol/skript/expressions/LitAt.java +++ b/src/main/java/ch/njol/skript/expressions/LitAt.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/LitConsole.java b/src/main/java/ch/njol/skript/expressions/LitConsole.java index 237cdb1dd06..23cac44ba93 100644 --- a/src/main/java/ch/njol/skript/expressions/LitConsole.java +++ b/src/main/java/ch/njol/skript/expressions/LitConsole.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/expressions/LitNewLine.java b/src/main/java/ch/njol/skript/expressions/LitNewLine.java index fbe845946a3..8281f216be7 100644 --- a/src/main/java/ch/njol/skript/expressions/LitNewLine.java +++ b/src/main/java/ch/njol/skript/expressions/LitNewLine.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/LitPi.java b/src/main/java/ch/njol/skript/expressions/LitPi.java index b1c6fe4c976..b4dfdf30f5b 100644 --- a/src/main/java/ch/njol/skript/expressions/LitPi.java +++ b/src/main/java/ch/njol/skript/expressions/LitPi.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticChain.java b/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticChain.java index df80686010b..f003f80441d 100644 --- a/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticChain.java +++ b/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticChain.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.arithmetic; import java.util.List; diff --git a/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticExpressionInfo.java b/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticExpressionInfo.java index 9f80830a541..8ee724a66c3 100644 --- a/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticExpressionInfo.java +++ b/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticExpressionInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.arithmetic; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticGettable.java b/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticGettable.java index 2bf076860df..14fdee7fe89 100644 --- a/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticGettable.java +++ b/src/main/java/ch/njol/skript/expressions/arithmetic/ArithmeticGettable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.arithmetic; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/expressions/arithmetic/ExprArithmetic.java b/src/main/java/ch/njol/skript/expressions/arithmetic/ExprArithmetic.java index 99026e9d40f..4916139842b 100644 --- a/src/main/java/ch/njol/skript/expressions/arithmetic/ExprArithmetic.java +++ b/src/main/java/ch/njol/skript/expressions/arithmetic/ExprArithmetic.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.arithmetic; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/expressions/arithmetic/NumberExpressionInfo.java b/src/main/java/ch/njol/skript/expressions/arithmetic/NumberExpressionInfo.java index 6c8ede2fff9..ff2e7289935 100644 --- a/src/main/java/ch/njol/skript/expressions/arithmetic/NumberExpressionInfo.java +++ b/src/main/java/ch/njol/skript/expressions/arithmetic/NumberExpressionInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.arithmetic; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/expressions/arithmetic/Operator.java b/src/main/java/ch/njol/skript/expressions/arithmetic/Operator.java index d3b983358fd..bc12caab9ee 100644 --- a/src/main/java/ch/njol/skript/expressions/arithmetic/Operator.java +++ b/src/main/java/ch/njol/skript/expressions/arithmetic/Operator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.arithmetic; @SuppressWarnings("UnnecessaryBoxing") diff --git a/src/main/java/ch/njol/skript/expressions/base/EventValueExpression.java b/src/main/java/ch/njol/skript/expressions/base/EventValueExpression.java index 6ba743179b8..a421691ddf5 100644 --- a/src/main/java/ch/njol/skript/expressions/base/EventValueExpression.java +++ b/src/main/java/ch/njol/skript/expressions/base/EventValueExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.base; import ch.njol.skript.Skript; @@ -36,7 +18,11 @@ import ch.njol.skript.registrations.EventValues; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Priority; import org.bukkit.event.Event; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.skriptlang.skript.lang.converter.Converter; @@ -65,6 +51,36 @@ */ public class EventValueExpression extends SimpleExpression implements DefaultExpression { + /** + * A priority for {@link EventValueExpression}s. + * They will be registered before {@link SyntaxInfo#COMBINED} expressions + * but after {@link SyntaxInfo#SIMPLE} expressions. + */ + @ApiStatus.Experimental + public static final Priority DEFAULT_PRIORITY = Priority.before(SyntaxInfo.COMBINED); + + /** + * Registers an event value expression with the provided pattern. + * The syntax info will be forced to use the {@link #DEFAULT_PRIORITY} priority. + * This also adds '[the]' to the start of the pattern. + * + * @param registry The SyntaxRegistry to register with. + * @param expressionClass The EventValueExpression class being registered. + * @param returnType The class representing the expression's return type. + * @param pattern The pattern to match for creating this expression. + * @param The return type. + * @param The Expression type. + * @return The registered {@link SyntaxInfo}. + */ + @ApiStatus.Experimental + public static , T> SyntaxInfo.Expression register(SyntaxRegistry registry, Class expressionClass, Class returnType, String pattern) { + SyntaxInfo.Expression info = SyntaxInfo.Expression.builder(expressionClass, returnType) + .priority(DEFAULT_PRIORITY) + .addPattern("[the] " + pattern) + .build(); + registry.register(SyntaxRegistry.EXPRESSION, info); + return info; + } /** * Registers an expression as {@link ExpressionType#EVENT} with the provided pattern. diff --git a/src/main/java/ch/njol/skript/expressions/base/PropertyExpression.java b/src/main/java/ch/njol/skript/expressions/base/PropertyExpression.java index 71f5efa9fca..29a569a4c65 100644 --- a/src/main/java/ch/njol/skript/expressions/base/PropertyExpression.java +++ b/src/main/java/ch/njol/skript/expressions/base/PropertyExpression.java @@ -8,13 +8,17 @@ import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.google.common.base.Preconditions; +import java.util.Arrays; import org.bukkit.event.Event; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.UnknownNullability; import org.skriptlang.skript.lang.converter.Converter; import org.skriptlang.skript.lang.converter.Converters; - -import java.util.Arrays; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Priority; /** * Represents an expression which represents a property of another one. Remember to set the expression with {@link #setExpr(Expression)} in @@ -27,18 +31,15 @@ public abstract class PropertyExpression extends SimpleExpression { /** * A helper method to get the property patterns given a property, type, and default expression parameter. - * - * @param property the property - * @param fromType the type(s) that the property should apply to - * @param defaultExpr whether the type(s) should be optional - * + * @param property the property + * @param fromType the type(s) that the property should apply to + * @param defaultExpr whether the type(s) should be optional * @return an array of strings representing the patterns of the given property and type(s) * @throws IllegalArgumentException if property or fromType is null */ private static String[] patternsOf(String property, String fromType, boolean defaultExpr) { - if (property == null || fromType == null) - throw new IllegalArgumentException("'property' or 'fromType' was null."); - + Preconditions.checkNotNull(property, "property must be present"); + Preconditions.checkNotNull(fromType, "fromType must be present"); String types = defaultExpr ? "[of %" + fromType + "%]" : "of %" + fromType + "%"; return new String[]{"[the] " + property + " " + types, "%" + fromType + "%'[s] " + property}; } @@ -71,6 +72,36 @@ public static String[] getDefaultPatterns(String property, String fromType) { return patternsOf(property, fromType, true); } + /** + * A priority for {@link PropertyExpression}s. + * They will be registered before {@link SyntaxInfo#PATTERN_MATCHES_EVERYTHING} expressions + * but after {@link SyntaxInfo#COMBINED} expressions. + */ + @ApiStatus.Experimental + public static final Priority DEFAULT_PRIORITY = Priority.before(SyntaxInfo.PATTERN_MATCHES_EVERYTHING); + + /** + * Registers an expression with the two default property patterns "property of %types%" and "%types%'[s] property" + * + * @param registry The SyntaxRegistry to register with. + * @param expressionClass The PropertyExpression class being registered. + * @param returnType The class representing the expression's return type. + * @param property The name of the property. + * @param fromType Should be plural to support multiple objects but doesn't have to be. + * @param The return type. + * @param The Expression type. + * @return The registered {@link SyntaxInfo}. + */ + @ApiStatus.Experimental + public static , T> SyntaxInfo.Expression register(SyntaxRegistry registry, Class expressionClass, Class returnType, String property, String fromType) { + SyntaxInfo.Expression info = SyntaxInfo.Expression.builder(expressionClass, returnType) + .priority(DEFAULT_PRIORITY) + .addPatterns(getPatterns(property, fromType)) + .build(); + registry.register(SyntaxRegistry.EXPRESSION, info); + return info; + } + /** * Registers an expression as {@link ExpressionType#PROPERTY} with the two default property patterns "property of %types%" and "%types%'[s] property" * @@ -83,6 +114,29 @@ public static void register(Class> expressionClass, Skript.registerExpression(expressionClass, type, ExpressionType.PROPERTY, getPatterns(property, fromType)); } + /** + * Registers an expression with the two default property patterns "property [of %types%]" and "%types%'[s] property" + * This method also makes the expression type optional to force a default expression on the property expression. + * + * @param registry The SyntaxRegistry to register with. + * @param expressionClass The PropertyExpression class being registered. + * @param returnType The class representing the expression's return type. + * @param property The name of the property. + * @param fromType Should be plural to support multiple objects but doesn't have to be. + * @param The return type. + * @param The Expression type. + * @return The registered {@link SyntaxInfo}. + */ + @ApiStatus.Experimental + public static , T> SyntaxInfo.Expression registerDefault(SyntaxRegistry registry, Class expressionClass, Class returnType, String property, String fromType) { + SyntaxInfo.Expression info = SyntaxInfo.Expression.builder(expressionClass, returnType) + .priority(DEFAULT_PRIORITY) + .addPatterns(getDefaultPatterns(property, fromType)) + .build(); + registry.register(SyntaxRegistry.EXPRESSION, info); + return info; + } + /** * Registers an expression as {@link ExpressionType#PROPERTY} with the two default property patterns "property [of %types%]" and "%types%'[s] property" * This method also makes the expression type optional to force a default expression on the property expression. diff --git a/src/main/java/ch/njol/skript/expressions/base/WrapperExpression.java b/src/main/java/ch/njol/skript/expressions/base/WrapperExpression.java index 63a8cee6635..f80c584d3fa 100644 --- a/src/main/java/ch/njol/skript/expressions/base/WrapperExpression.java +++ b/src/main/java/ch/njol/skript/expressions/base/WrapperExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.expressions.base; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/hooks/Hook.java b/src/main/java/ch/njol/skript/hooks/Hook.java index c0d415c2786..cfeb5ecf5c2 100644 --- a/src/main/java/ch/njol/skript/hooks/Hook.java +++ b/src/main/java/ch/njol/skript/hooks/Hook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/hooks/VaultHook.java b/src/main/java/ch/njol/skript/hooks/VaultHook.java index 8377e8bc1d8..3412c3df62c 100644 --- a/src/main/java/ch/njol/skript/hooks/VaultHook.java +++ b/src/main/java/ch/njol/skript/hooks/VaultHook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/hooks/economy/classes/Money.java b/src/main/java/ch/njol/skript/hooks/economy/classes/Money.java index dafe28d61e6..821d2824149 100644 --- a/src/main/java/ch/njol/skript/hooks/economy/classes/Money.java +++ b/src/main/java/ch/njol/skript/hooks/economy/classes/Money.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.economy.classes; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/economy/expressions/ExprBalance.java b/src/main/java/ch/njol/skript/hooks/economy/expressions/ExprBalance.java index 4c02eea8e33..609720efe0e 100644 --- a/src/main/java/ch/njol/skript/hooks/economy/expressions/ExprBalance.java +++ b/src/main/java/ch/njol/skript/hooks/economy/expressions/ExprBalance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.economy.expressions; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprAllGroups.java b/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprAllGroups.java index aecf98fa30e..b7ad68b6e74 100644 --- a/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprAllGroups.java +++ b/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprAllGroups.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.permission.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprGroup.java b/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprGroup.java index 054d065c96d..a04fceea5ef 100644 --- a/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprGroup.java +++ b/src/main/java/ch/njol/skript/hooks/permission/expressions/ExprGroup.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.permission.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/GriefPreventionHook.java b/src/main/java/ch/njol/skript/hooks/regions/GriefPreventionHook.java index a7fa61cb376..77f1722acfa 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/GriefPreventionHook.java +++ b/src/main/java/ch/njol/skript/hooks/regions/GriefPreventionHook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/hooks/regions/PreciousStonesHook.java b/src/main/java/ch/njol/skript/hooks/regions/PreciousStonesHook.java index a0094373307..82e8a318e1e 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/PreciousStonesHook.java +++ b/src/main/java/ch/njol/skript/hooks/regions/PreciousStonesHook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions; import static ch.njol.skript.variables.Variables.yggdrasil; diff --git a/src/main/java/ch/njol/skript/hooks/regions/RegionsPlugin.java b/src/main/java/ch/njol/skript/hooks/regions/RegionsPlugin.java index c2f2fb46d32..b729a69839d 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/RegionsPlugin.java +++ b/src/main/java/ch/njol/skript/hooks/regions/RegionsPlugin.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/hooks/regions/ResidenceHook.java b/src/main/java/ch/njol/skript/hooks/regions/ResidenceHook.java index d342cf8840b..e966dba318c 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/ResidenceHook.java +++ b/src/main/java/ch/njol/skript/hooks/regions/ResidenceHook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/hooks/regions/WorldGuardHook.java b/src/main/java/ch/njol/skript/hooks/regions/WorldGuardHook.java index f9cd9bc0670..7dc975b4acd 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/WorldGuardHook.java +++ b/src/main/java/ch/njol/skript/hooks/regions/WorldGuardHook.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/hooks/regions/classes/Region.java b/src/main/java/ch/njol/skript/hooks/regions/classes/Region.java index fe60beef3f5..631f38e2a46 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/classes/Region.java +++ b/src/main/java/ch/njol/skript/hooks/regions/classes/Region.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.classes; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/conditions/CondCanBuild.java b/src/main/java/ch/njol/skript/hooks/regions/conditions/CondCanBuild.java index 5b9ac5390b9..adfc02fa728 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/conditions/CondCanBuild.java +++ b/src/main/java/ch/njol/skript/hooks/regions/conditions/CondCanBuild.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/conditions/CondIsMember.java b/src/main/java/ch/njol/skript/hooks/regions/conditions/CondIsMember.java index b89c9aae201..fa7070d103e 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/conditions/CondIsMember.java +++ b/src/main/java/ch/njol/skript/hooks/regions/conditions/CondIsMember.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/conditions/CondRegionContains.java b/src/main/java/ch/njol/skript/hooks/regions/conditions/CondRegionContains.java index 340540f0180..177e731c354 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/conditions/CondRegionContains.java +++ b/src/main/java/ch/njol/skript/hooks/regions/conditions/CondRegionContains.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.conditions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/events/EvtRegionBorder.java b/src/main/java/ch/njol/skript/hooks/regions/events/EvtRegionBorder.java index d338b8f9fcb..509509abbb5 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/events/EvtRegionBorder.java +++ b/src/main/java/ch/njol/skript/hooks/regions/events/EvtRegionBorder.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.events; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/events/RegionBorderEvent.java b/src/main/java/ch/njol/skript/hooks/regions/events/RegionBorderEvent.java index f2d08cecf7a..d75fc92730f 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/events/RegionBorderEvent.java +++ b/src/main/java/ch/njol/skript/hooks/regions/events/RegionBorderEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.events; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprBlocksInRegion.java b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprBlocksInRegion.java index eaa6af8c785..fd61ee3b16c 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprBlocksInRegion.java +++ b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprBlocksInRegion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprMembersOfRegion.java b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprMembersOfRegion.java index bd4db9cb447..883b609bf05 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprMembersOfRegion.java +++ b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprMembersOfRegion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegion.java b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegion.java index a0b1426e3ce..3b92975e9e2 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegion.java +++ b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegion.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.expressions; import ch.njol.skript.doc.Description; diff --git a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegionsAt.java b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegionsAt.java index 0e2c80aa20b..a122a9d3cb4 100644 --- a/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegionsAt.java +++ b/src/main/java/ch/njol/skript/hooks/regions/expressions/ExprRegionsAt.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.hooks.regions.expressions; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/Condition.java b/src/main/java/ch/njol/skript/lang/Condition.java index 5e3d287fce1..31a1810d2b0 100644 --- a/src/main/java/ch/njol/skript/lang/Condition.java +++ b/src/main/java/ch/njol/skript/lang/Condition.java @@ -1,30 +1,16 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; +import ch.njol.skript.conditions.base.PropertyCondition; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Checker; import ch.njol.util.Kleenean; import org.bukkit.event.Event; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.skriptlang.skript.lang.condition.Conditional; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.util.Priority; import java.util.Iterator; @@ -41,17 +27,34 @@ public enum ConditionType { * * @see #PROPERTY */ - COMBINED, + COMBINED(SyntaxInfo.COMBINED), /** * Property conditions, e.g. "%properties% is/are data value[s]" */ - PROPERTY, + PROPERTY(PropertyCondition.DEFAULT_PRIORITY), /** * Conditions whose pattern matches (almost) everything or should be last checked. */ - PATTERN_MATCHES_EVERYTHING; + PATTERN_MATCHES_EVERYTHING(SyntaxInfo.PATTERN_MATCHES_EVERYTHING); + + @ApiStatus.Experimental + private final Priority priority; + + @ApiStatus.Experimental + ConditionType(Priority priority) { + this.priority = priority; + } + + /** + * @return The Priority equivalent of this ConditionType. + */ + @ApiStatus.Experimental + public Priority priority() { + return this.priority; + } + } private boolean negated; diff --git a/src/main/java/ch/njol/skript/lang/Debuggable.java b/src/main/java/ch/njol/skript/lang/Debuggable.java index 98714194d32..a89660b6124 100644 --- a/src/main/java/ch/njol/skript/lang/Debuggable.java +++ b/src/main/java/ch/njol/skript/lang/Debuggable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/lang/DefaultExpression.java b/src/main/java/ch/njol/skript/lang/DefaultExpression.java index 86140cd57db..57a62e70fb0 100644 --- a/src/main/java/ch/njol/skript/lang/DefaultExpression.java +++ b/src/main/java/ch/njol/skript/lang/DefaultExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; /** diff --git a/src/main/java/ch/njol/skript/lang/Effect.java b/src/main/java/ch/njol/skript/lang/Effect.java index e8d2338313a..ee71112c5d4 100644 --- a/src/main/java/ch/njol/skript/lang/Effect.java +++ b/src/main/java/ch/njol/skript/lang/Effect.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/EffectSection.java b/src/main/java/ch/njol/skript/lang/EffectSection.java index 070812277c6..65b6d49d135 100644 --- a/src/main/java/ch/njol/skript/lang/EffectSection.java +++ b/src/main/java/ch/njol/skript/lang/EffectSection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/EffectSectionEffect.java b/src/main/java/ch/njol/skript/lang/EffectSectionEffect.java index 3cc1916e700..985c42ab260 100644 --- a/src/main/java/ch/njol/skript/lang/EffectSectionEffect.java +++ b/src/main/java/ch/njol/skript/lang/EffectSectionEffect.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.lang.SkriptParser.ParseResult; diff --git a/src/main/java/ch/njol/skript/lang/EventRestrictedSyntax.java b/src/main/java/ch/njol/skript/lang/EventRestrictedSyntax.java new file mode 100644 index 00000000000..901c23d6ece --- /dev/null +++ b/src/main/java/ch/njol/skript/lang/EventRestrictedSyntax.java @@ -0,0 +1,25 @@ +package ch.njol.skript.lang; + +import ch.njol.util.Kleenean; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.event.Event; + +/** + * A syntax element that restricts the events it can be used in. + */ +public interface EventRestrictedSyntax { + + /** + * Returns all supported events for this syntax element. + *

+ * Before {@link SyntaxElement#init(Expression[], int, Kleenean, SkriptParser.ParseResult)} is called, checks + * to see if the current event is supported by this syntax element. + * If it is not, an error will be printed and the syntax element will not be initialised. + *

+ * + * @return All supported event classes. + * @see CollectionUtils#array(Object[]) + */ + Class[] supportedEvents(); + +} diff --git a/src/main/java/ch/njol/skript/lang/Expression.java b/src/main/java/ch/njol/skript/lang/Expression.java index d8bc4006adf..6b853136ee0 100644 --- a/src/main/java/ch/njol/skript/lang/Expression.java +++ b/src/main/java/ch/njol/skript/lang/Expression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/ExpressionInfo.java b/src/main/java/ch/njol/skript/lang/ExpressionInfo.java index 2d4f1ec83c0..feeba7bd785 100644 --- a/src/main/java/ch/njol/skript/lang/ExpressionInfo.java +++ b/src/main/java/ch/njol/skript/lang/ExpressionInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/lang/ExpressionList.java b/src/main/java/ch/njol/skript/lang/ExpressionList.java index a99a1b21662..ccd9efcb50a 100644 --- a/src/main/java/ch/njol/skript/lang/ExpressionList.java +++ b/src/main/java/ch/njol/skript/lang/ExpressionList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.classes.Changer.ChangeMode; diff --git a/src/main/java/ch/njol/skript/lang/ExpressionType.java b/src/main/java/ch/njol/skript/lang/ExpressionType.java index 7f16051ee57..b47c538e884 100644 --- a/src/main/java/ch/njol/skript/lang/ExpressionType.java +++ b/src/main/java/ch/njol/skript/lang/ExpressionType.java @@ -1,25 +1,11 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.expressions.base.EventValueExpression; import ch.njol.skript.expressions.base.PropertyExpression; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.util.Priority; /** * Used to define in which order to parse expressions. @@ -29,32 +15,63 @@ public enum ExpressionType { /** * Expressions that only match simple text, e.g. "[the] player" */ - SIMPLE, + SIMPLE(SyntaxInfo.SIMPLE), /** * Expressions that are related to the Event that are typically simple. * * @see EventValueExpression */ - EVENT, + EVENT(EventValueExpression.DEFAULT_PRIORITY), /** * Expressions that contain other expressions, e.g. "[the] distance between %location% and %location%" * * @see #PROPERTY */ - COMBINED, + COMBINED(SyntaxInfo.COMBINED), /** * Property expressions, e.g. "[the] data value[s] of %items%"/"%items%'[s] data value[s]" * * @see PropertyExpression */ - PROPERTY, + PROPERTY(PropertyExpression.DEFAULT_PRIORITY), /** * Expressions whose pattern matches (almost) everything. Typically when using regex. Example: "[the] [loop-]<.+>" */ - PATTERN_MATCHES_EVERYTHING; + PATTERN_MATCHES_EVERYTHING(SyntaxInfo.PATTERN_MATCHES_EVERYTHING); + + @ApiStatus.Experimental + private final Priority priority; + + @ApiStatus.Experimental + ExpressionType(Priority priority) { + this.priority = priority; + } + + /** + * @return The Priority equivalent of this ExpressionType. + */ + @ApiStatus.Experimental + public Priority priority() { + return priority; + } + + @ApiStatus.Experimental + public static @Nullable ExpressionType fromModern(Priority priority) { + if (priority == SyntaxInfo.SIMPLE) + return ExpressionType.SIMPLE; + if (priority == EventValueExpression.DEFAULT_PRIORITY) + return ExpressionType.EVENT; + if (priority == SyntaxInfo.COMBINED) + return ExpressionType.COMBINED; + if (priority == PropertyExpression.DEFAULT_PRIORITY) + return ExpressionType.PROPERTY; + if (priority == SyntaxInfo.PATTERN_MATCHES_EVERYTHING) + return ExpressionType.PATTERN_MATCHES_EVERYTHING; + return null; + } } diff --git a/src/main/java/ch/njol/skript/lang/InputSource.java b/src/main/java/ch/njol/skript/lang/InputSource.java index f996557bcdc..e7cf1757156 100644 --- a/src/main/java/ch/njol/skript/lang/InputSource.java +++ b/src/main/java/ch/njol/skript/lang/InputSource.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.expressions.ExprInput; diff --git a/src/main/java/ch/njol/skript/lang/Literal.java b/src/main/java/ch/njol/skript/lang/Literal.java index c3fe27cf0aa..a685f3c2e30 100644 --- a/src/main/java/ch/njol/skript/lang/Literal.java +++ b/src/main/java/ch/njol/skript/lang/Literal.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/lang/LiteralList.java b/src/main/java/ch/njol/skript/lang/LiteralList.java index df2d8d51966..af0db3ca6ff 100644 --- a/src/main/java/ch/njol/skript/lang/LiteralList.java +++ b/src/main/java/ch/njol/skript/lang/LiteralList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.lang.util.SimpleLiteral; diff --git a/src/main/java/ch/njol/skript/lang/LiteralString.java b/src/main/java/ch/njol/skript/lang/LiteralString.java index 588bd1e5691..f26b1d9d919 100644 --- a/src/main/java/ch/njol/skript/lang/LiteralString.java +++ b/src/main/java/ch/njol/skript/lang/LiteralString.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.lang.util.ConvertedLiteral; diff --git a/src/main/java/ch/njol/skript/lang/LoopSection.java b/src/main/java/ch/njol/skript/lang/LoopSection.java index b126a8889c6..6c073faa63c 100644 --- a/src/main/java/ch/njol/skript/lang/LoopSection.java +++ b/src/main/java/ch/njol/skript/lang/LoopSection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/lang/ParseContext.java b/src/main/java/ch/njol/skript/lang/ParseContext.java index ecac65279e7..c1dca4677de 100644 --- a/src/main/java/ch/njol/skript/lang/ParseContext.java +++ b/src/main/java/ch/njol/skript/lang/ParseContext.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; /** diff --git a/src/main/java/ch/njol/skript/lang/ReturnHandler.java b/src/main/java/ch/njol/skript/lang/ReturnHandler.java index d905599dc4b..e12a0482027 100644 --- a/src/main/java/ch/njol/skript/lang/ReturnHandler.java +++ b/src/main/java/ch/njol/skript/lang/ReturnHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/lang/ReturnableTrigger.java b/src/main/java/ch/njol/skript/lang/ReturnableTrigger.java index 08b6cea873e..90629b0776d 100644 --- a/src/main/java/ch/njol/skript/lang/ReturnableTrigger.java +++ b/src/main/java/ch/njol/skript/lang/ReturnableTrigger.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/lang/Section.java b/src/main/java/ch/njol/skript/lang/Section.java index 17401f559c7..f39647aec15 100644 --- a/src/main/java/ch/njol/skript/lang/Section.java +++ b/src/main/java/ch/njol/skript/lang/Section.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/lang/SectionExitHandler.java b/src/main/java/ch/njol/skript/lang/SectionExitHandler.java index 3b081245fdb..fd034735da4 100644 --- a/src/main/java/ch/njol/skript/lang/SectionExitHandler.java +++ b/src/main/java/ch/njol/skript/lang/SectionExitHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/lang/SectionSkriptEvent.java b/src/main/java/ch/njol/skript/lang/SectionSkriptEvent.java index 05d8490aae7..ec03f1152ff 100644 --- a/src/main/java/ch/njol/skript/lang/SectionSkriptEvent.java +++ b/src/main/java/ch/njol/skript/lang/SectionSkriptEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.SkriptAPIException; diff --git a/src/main/java/ch/njol/skript/lang/SelfRegisteringSkriptEvent.java b/src/main/java/ch/njol/skript/lang/SelfRegisteringSkriptEvent.java index 00b9f607620..feeec22fe73 100644 --- a/src/main/java/ch/njol/skript/lang/SelfRegisteringSkriptEvent.java +++ b/src/main/java/ch/njol/skript/lang/SelfRegisteringSkriptEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.config.Config; diff --git a/src/main/java/ch/njol/skript/lang/SkriptEvent.java b/src/main/java/ch/njol/skript/lang/SkriptEvent.java index ec85f9fd266..c7eb245fb22 100644 --- a/src/main/java/ch/njol/skript/lang/SkriptEvent.java +++ b/src/main/java/ch/njol/skript/lang/SkriptEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.ScriptLoader; @@ -26,10 +8,11 @@ import ch.njol.skript.events.EvtClick; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.structures.StructEvent.EventData; -import ch.njol.skript.util.Utils; -import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.EventPriority; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; +import ch.njol.skript.util.Utils; +import org.bukkit.event.Cancellable; import org.jetbrains.annotations.Nullable; import org.skriptlang.skript.lang.entry.EntryContainer; import org.skriptlang.skript.lang.script.Script; @@ -256,29 +239,7 @@ public boolean canExecuteAsynchronously() { * to be nullable. */ public static String fixPattern(String pattern) { - char[] chars = pattern.toCharArray(); - StringBuilder stringBuilder = new StringBuilder(); - - boolean inType = false; - for (int i = 0; i < chars.length; i++) { - char character = chars[i]; - stringBuilder.append(character); - - if (character == '%') { - // toggle inType - inType = !inType; - - // add the dash character if it's not already present - // a type specification can have two prefix characters for modification - if (inType && i + 2 < chars.length && chars[i + 1] != '-' && chars[i + 2] != '-') - stringBuilder.append('-'); - } else if (character == '\\' && i + 1 < chars.length) { - // Make sure we don't toggle inType for escape percentage signs - stringBuilder.append(chars[i + 1]); - i++; - } - } - return stringBuilder.toString(); + return BukkitSyntaxInfos.fixPattern(pattern); } @Nullable diff --git a/src/main/java/ch/njol/skript/lang/SkriptEventInfo.java b/src/main/java/ch/njol/skript/lang/SkriptEventInfo.java index 78d32c9b023..c083adaf7ad 100644 --- a/src/main/java/ch/njol/skript/lang/SkriptEventInfo.java +++ b/src/main/java/ch/njol/skript/lang/SkriptEventInfo.java @@ -1,34 +1,28 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; +import ch.njol.skript.Skript; import ch.njol.skript.SkriptAPIException; import ch.njol.skript.SkriptConfig; import ch.njol.skript.lang.SkriptEvent.ListeningBehavior; +import ch.njol.skript.lang.SkriptEventInfo.ModernSkriptEventInfo; import org.bukkit.event.Event; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; import org.skriptlang.skript.lang.structure.StructureInfo; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.registration.SyntaxOrigin; +import org.skriptlang.skript.util.Priority; +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; +import java.util.List; import java.util.Locale; -public final class SkriptEventInfo extends StructureInfo { +public sealed class SkriptEventInfo extends StructureInfo permits ModernSkriptEventInfo { public Class[] events; public final String name; @@ -200,4 +194,125 @@ public ListeningBehavior getListeningBehavior() { return documentationID; } + /* + * Registration API Compatibility + */ + + /** + * Internal wrapper class for providing compatibility with the new Registration API. + */ + @ApiStatus.Internal + @ApiStatus.Experimental + public static final class ModernSkriptEventInfo + extends SkriptEventInfo + implements BukkitSyntaxInfos.Event { + + private final SyntaxOrigin origin; + + public ModernSkriptEventInfo(String name, String[] patterns, Class eventClass, String originClassPath, Class[] events) { + super(name, patterns, eventClass, originClassPath, events); + origin = SyntaxOrigin.of(Skript.getAddon(JavaPlugin.getProvidingPlugin(eventClass))); + } + + @Override + public Builder, E> builder() { + return BukkitSyntaxInfos.Event.builder(type(), name()) + .origin(origin) + .addPatterns(patterns()) + .priority(priority()) + .listeningBehavior(listeningBehavior()) + .since(since()) + .documentationId(id()) + .addDescription(description()) + .addExamples(examples()) + .addKeywords(keywords()) + .addRequiredPlugins(requiredPlugins()) + .addEvents(events()); + } + + @Override + public SyntaxOrigin origin() { + return origin; + } + + @Override + public Class type() { + return getElementClass(); + } + + @Override + public E instance() { + try { + return type().getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | + NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + + @Override + public @Unmodifiable Collection patterns() { + return List.of(getPatterns()); + } + + @Override + public Priority priority() { + return SyntaxInfo.COMBINED; + } + + @Override + public ListeningBehavior listeningBehavior() { + return getListeningBehavior(); + } + + @Override + public String name() { + return getName(); + } + + @Override + public String id() { + return getId(); + } + + @Override + public @Nullable String since() { + return getSince(); + } + + @Override + public @Nullable String documentationId() { + return getDocumentationID(); + } + + @Override + public Collection description() { + String[] description = getDescription(); + return description != null ? List.of(description) : List.of(); + } + + @Override + public Collection examples() { + String[] examples = getExamples(); + return examples != null ? List.of(examples) : List.of(); + } + + @Override + public Collection keywords() { + String[] keywords = getKeywords(); + return keywords != null ? List.of(keywords) : List.of(); + } + + @Override + public Collection requiredPlugins() { + String[] requiredPlugins = getRequiredPlugins(); + return requiredPlugins != null ? List.of(requiredPlugins) : List.of(); + } + + @Override + public Collection> events() { + return List.of(events); + } + } + } diff --git a/src/main/java/ch/njol/skript/lang/SkriptParser.java b/src/main/java/ch/njol/skript/lang/SkriptParser.java index e713edeb750..79d94bf6ebc 100644 --- a/src/main/java/ch/njol/skript/lang/SkriptParser.java +++ b/src/main/java/ch/njol/skript/lang/SkriptParser.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; @@ -49,19 +31,14 @@ import ch.njol.util.StringUtils; import ch.njol.util.coll.CollectionUtils; import com.google.common.primitives.Booleans; +import org.bukkit.event.Event; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.skriptlang.skript.lang.script.Script; import org.skriptlang.skript.lang.script.ScriptWarning; -import java.util.ArrayList; -import java.util.Deque; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; @@ -243,7 +220,26 @@ public boolean hasTag(String tag) { } } T element = info.getElementClass().newInstance(); - if (element.init(parseResult.exprs, patternIndex, getParser().getHasDelayBefore(), parseResult)) { + + if (element instanceof EventRestrictedSyntax eventRestrictedSyntax) { + Class[] supportedEvents = eventRestrictedSyntax.supportedEvents(); + if (!getParser().isCurrentEvent(supportedEvents)) { + Iterator iterator = Arrays.stream(supportedEvents) + .map(it -> "the " + it.getSimpleName() + .replaceAll("([A-Z])", " $1") + .toLowerCase() + .trim()) + .iterator(); + + String events = StringUtils.join(iterator, ", ", " or "); + + Skript.error("'" + parseResult.expr + "' can only be used in " + events); + continue; + } + } + + boolean success = element.init(parseResult.exprs, patternIndex, getParser().getHasDelayBefore(), parseResult); + if (success) { log.printLog(); return element; } diff --git a/src/main/java/ch/njol/skript/lang/SyntaxElement.java b/src/main/java/ch/njol/skript/lang/SyntaxElement.java index 5ab3589733c..d0ada62cf69 100644 --- a/src/main/java/ch/njol/skript/lang/SyntaxElement.java +++ b/src/main/java/ch/njol/skript/lang/SyntaxElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.lang.SkriptParser.ParseResult; diff --git a/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java b/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java index 3945d2eb02b..2724451d23d 100644 --- a/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java +++ b/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java @@ -1,30 +1,18 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; +import org.bukkit.event.Event; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.lang.structure.StructureInfo; + import ch.njol.skript.SkriptAPIException; import java.lang.reflect.Modifier; import java.util.Arrays; /** - * @author Peter Güttinger * @param the syntax element this info is for */ public class SyntaxElementInfo { @@ -74,4 +62,50 @@ public String[] getPatterns() { public String getOriginClassPath() { return originClassPath; } + + @Contract("_ -> new") + @ApiStatus.Experimental + @SuppressWarnings("unchecked") + public static , E extends SyntaxElement> I fromModern(SyntaxInfo info) { + if (info instanceof BukkitSyntaxInfos.Event event) { + // We must first go back to the raw input + String rawName = event.name().startsWith("On ") + ? event.name().substring(3) + : "*" + event.name(); + SkriptEventInfo eventInfo = new SkriptEventInfo<>( + rawName, event.patterns().toArray(new String[0]), + event.type(), event.origin().name(), + (Class[]) event.events().toArray(new Class[0])); + String since = event.since(); + if (since != null) + eventInfo.since(since); + String documentationId = event.documentationId(); + if (documentationId != null) + eventInfo.documentationID(documentationId); + eventInfo.listeningBehavior(event.listeningBehavior()) + .description(event.description().toArray(new String[0])) + .examples(event.examples().toArray(new String[0])) + .keywords(event.keywords().toArray(new String[0])) + .requiredPlugins(event.requiredPlugins().toArray(new String[0])); + + return (I) eventInfo; + } else if (info instanceof SyntaxInfo.Structure structure) { + return (I) new StructureInfo<>(structure.patterns().toArray(new String[0]), structure.type(), + structure.origin().name(), structure.entryValidator(), structure.nodeType()); + } else if (info instanceof SyntaxInfo.Expression expression) { + return (I) fromModernExpression(expression); + } + + return (I) new SyntaxElementInfo<>(info.patterns().toArray(new String[0]), info.type(), info.origin().name()); + } + + @Contract("_ -> new") + @ApiStatus.Experimental + private static , R> ExpressionInfo fromModernExpression(SyntaxInfo.Expression info) { + return new ExpressionInfo<>( + info.patterns().toArray(new String[0]), info.returnType(), + info.type(), info.origin().name(), ExpressionType.fromModern(info.priority()) + ); + } + } diff --git a/src/main/java/ch/njol/skript/lang/Trigger.java b/src/main/java/ch/njol/skript/lang/Trigger.java index d6e18a1f5ee..578ee748329 100644 --- a/src/main/java/ch/njol/skript/lang/Trigger.java +++ b/src/main/java/ch/njol/skript/lang/Trigger.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.variables.Variables; diff --git a/src/main/java/ch/njol/skript/lang/TriggerItem.java b/src/main/java/ch/njol/skript/lang/TriggerItem.java index 6a517a6c601..d8a21916709 100644 --- a/src/main/java/ch/njol/skript/lang/TriggerItem.java +++ b/src/main/java/ch/njol/skript/lang/TriggerItem.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/TriggerSection.java b/src/main/java/ch/njol/skript/lang/TriggerSection.java index 2f479f88791..67430f304b6 100644 --- a/src/main/java/ch/njol/skript/lang/TriggerSection.java +++ b/src/main/java/ch/njol/skript/lang/TriggerSection.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/lang/Unit.java b/src/main/java/ch/njol/skript/lang/Unit.java index c1c237d83a6..e3829122340 100644 --- a/src/main/java/ch/njol/skript/lang/Unit.java +++ b/src/main/java/ch/njol/skript/lang/Unit.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; public interface Unit extends Cloneable { diff --git a/src/main/java/ch/njol/skript/lang/UnparsedLiteral.java b/src/main/java/ch/njol/skript/lang/UnparsedLiteral.java index 469ef7aa81d..202fab7fee9 100644 --- a/src/main/java/ch/njol/skript/lang/UnparsedLiteral.java +++ b/src/main/java/ch/njol/skript/lang/UnparsedLiteral.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.SkriptAPIException; diff --git a/src/main/java/ch/njol/skript/lang/VariableString.java b/src/main/java/ch/njol/skript/lang/VariableString.java index a44694cc6d3..cbbddd753fd 100644 --- a/src/main/java/ch/njol/skript/lang/VariableString.java +++ b/src/main/java/ch/njol/skript/lang/VariableString.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/VerboseAssert.java b/src/main/java/ch/njol/skript/lang/VerboseAssert.java index 721de83e0c9..000616272a1 100644 --- a/src/main/java/ch/njol/skript/lang/VerboseAssert.java +++ b/src/main/java/ch/njol/skript/lang/VerboseAssert.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang; import ch.njol.skript.registrations.Classes; diff --git a/src/main/java/ch/njol/skript/lang/function/EffFunctionCall.java b/src/main/java/ch/njol/skript/lang/function/EffFunctionCall.java index 464e7ee4238..10dd821b017 100644 --- a/src/main/java/ch/njol/skript/lang/function/EffFunctionCall.java +++ b/src/main/java/ch/njol/skript/lang/function/EffFunctionCall.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/lang/function/ExprFunctionCall.java b/src/main/java/ch/njol/skript/lang/function/ExprFunctionCall.java index 1352788ecfe..903bc44b67c 100644 --- a/src/main/java/ch/njol/skript/lang/function/ExprFunctionCall.java +++ b/src/main/java/ch/njol/skript/lang/function/ExprFunctionCall.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/lang/function/Function.java b/src/main/java/ch/njol/skript/lang/function/Function.java index b358844dea4..89e3b48452f 100644 --- a/src/main/java/ch/njol/skript/lang/function/Function.java +++ b/src/main/java/ch/njol/skript/lang/function/Function.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.SkriptConfig; diff --git a/src/main/java/ch/njol/skript/lang/function/FunctionEvent.java b/src/main/java/ch/njol/skript/lang/function/FunctionEvent.java index c954d434bcd..6e17b1410d1 100644 --- a/src/main/java/ch/njol/skript/lang/function/FunctionEvent.java +++ b/src/main/java/ch/njol/skript/lang/function/FunctionEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/lang/function/FunctionReference.java b/src/main/java/ch/njol/skript/lang/function/FunctionReference.java index f60f480ad8c..09c75f9bfa3 100644 --- a/src/main/java/ch/njol/skript/lang/function/FunctionReference.java +++ b/src/main/java/ch/njol/skript/lang/function/FunctionReference.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; diff --git a/src/main/java/ch/njol/skript/lang/function/Functions.java b/src/main/java/ch/njol/skript/lang/function/Functions.java index 71bbd568d5d..bac1537d899 100644 --- a/src/main/java/ch/njol/skript/lang/function/Functions.java +++ b/src/main/java/ch/njol/skript/lang/function/Functions.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/function/JavaFunction.java b/src/main/java/ch/njol/skript/lang/function/JavaFunction.java index 6806a5b97c8..74c19cb8e20 100644 --- a/src/main/java/ch/njol/skript/lang/function/JavaFunction.java +++ b/src/main/java/ch/njol/skript/lang/function/JavaFunction.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.classes.ClassInfo; diff --git a/src/main/java/ch/njol/skript/lang/function/Namespace.java b/src/main/java/ch/njol/skript/lang/function/Namespace.java index be649efd1b0..123428c7ce3 100644 --- a/src/main/java/ch/njol/skript/lang/function/Namespace.java +++ b/src/main/java/ch/njol/skript/lang/function/Namespace.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/lang/function/Parameter.java b/src/main/java/ch/njol/skript/lang/function/Parameter.java index 87707ff7b05..e9ab79f63ec 100644 --- a/src/main/java/ch/njol/skript/lang/function/Parameter.java +++ b/src/main/java/ch/njol/skript/lang/function/Parameter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/function/ScriptFunction.java b/src/main/java/ch/njol/skript/lang/function/ScriptFunction.java index a864537cb00..c6441333b19 100644 --- a/src/main/java/ch/njol/skript/lang/function/ScriptFunction.java +++ b/src/main/java/ch/njol/skript/lang/function/ScriptFunction.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.classes.ClassInfo; diff --git a/src/main/java/ch/njol/skript/lang/function/Signature.java b/src/main/java/ch/njol/skript/lang/function/Signature.java index a4e4b05cd56..f046fecc6e6 100644 --- a/src/main/java/ch/njol/skript/lang/function/Signature.java +++ b/src/main/java/ch/njol/skript/lang/function/Signature.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/function/SimpleJavaFunction.java b/src/main/java/ch/njol/skript/lang/function/SimpleJavaFunction.java index 3e5c056d686..32d264ac361 100644 --- a/src/main/java/ch/njol/skript/lang/function/SimpleJavaFunction.java +++ b/src/main/java/ch/njol/skript/lang/function/SimpleJavaFunction.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.function; import ch.njol.skript.classes.ClassInfo; diff --git a/src/main/java/ch/njol/skript/lang/parser/ParserInstance.java b/src/main/java/ch/njol/skript/lang/parser/ParserInstance.java index 3e05612c0a7..bbb8b75340d 100644 --- a/src/main/java/ch/njol/skript/lang/parser/ParserInstance.java +++ b/src/main/java/ch/njol/skript/lang/parser/ParserInstance.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.parser; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/lang/util/ContainerExpression.java b/src/main/java/ch/njol/skript/lang/util/ContainerExpression.java index c0aa1518128..4b71417416a 100644 --- a/src/main/java/ch/njol/skript/lang/util/ContainerExpression.java +++ b/src/main/java/ch/njol/skript/lang/util/ContainerExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/lang/util/ContextlessEvent.java b/src/main/java/ch/njol/skript/lang/util/ContextlessEvent.java index 9338fcc73ee..9e786176ffa 100644 --- a/src/main/java/ch/njol/skript/lang/util/ContextlessEvent.java +++ b/src/main/java/ch/njol/skript/lang/util/ContextlessEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.lang.parser.ParserInstance; diff --git a/src/main/java/ch/njol/skript/lang/util/ConvertedExpression.java b/src/main/java/ch/njol/skript/lang/util/ConvertedExpression.java index cdda53f68bd..70c41575ab8 100644 --- a/src/main/java/ch/njol/skript/lang/util/ConvertedExpression.java +++ b/src/main/java/ch/njol/skript/lang/util/ConvertedExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.classes.Changer; diff --git a/src/main/java/ch/njol/skript/lang/util/ConvertedLiteral.java b/src/main/java/ch/njol/skript/lang/util/ConvertedLiteral.java index 23d8890f924..4336f9cca26 100644 --- a/src/main/java/ch/njol/skript/lang/util/ConvertedLiteral.java +++ b/src/main/java/ch/njol/skript/lang/util/ConvertedLiteral.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.SkriptAPIException; diff --git a/src/main/java/ch/njol/skript/lang/util/SimpleEvent.java b/src/main/java/ch/njol/skript/lang/util/SimpleEvent.java index b482204af33..5f26638893f 100644 --- a/src/main/java/ch/njol/skript/lang/util/SimpleEvent.java +++ b/src/main/java/ch/njol/skript/lang/util/SimpleEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.SkriptAPIException; diff --git a/src/main/java/ch/njol/skript/lang/util/SimpleExpression.java b/src/main/java/ch/njol/skript/lang/util/SimpleExpression.java index 0a88f14020e..909035cceb6 100644 --- a/src/main/java/ch/njol/skript/lang/util/SimpleExpression.java +++ b/src/main/java/ch/njol/skript/lang/util/SimpleExpression.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/lang/util/SimpleLiteral.java b/src/main/java/ch/njol/skript/lang/util/SimpleLiteral.java index db7ed90f29c..64872659b2b 100644 --- a/src/main/java/ch/njol/skript/lang/util/SimpleLiteral.java +++ b/src/main/java/ch/njol/skript/lang/util/SimpleLiteral.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.lang.util; import ch.njol.skript.classes.Changer; diff --git a/src/main/java/ch/njol/skript/lang/util/common/AnyAmount.java b/src/main/java/ch/njol/skript/lang/util/common/AnyAmount.java new file mode 100644 index 00000000000..9232f45826e --- /dev/null +++ b/src/main/java/ch/njol/skript/lang/util/common/AnyAmount.java @@ -0,0 +1,49 @@ +package ch.njol.skript.lang.util.common; + +import org.jetbrains.annotations.NotNull; + +/** + * A provider for anything with a (number) amount/size. + * Anything implementing this (or convertible to this) can be used by the {@link ch.njol.skript.expressions.ExprAmount} + * property expression. + * + * @see AnyProvider + */ +@FunctionalInterface +public interface AnyAmount extends AnyProvider { + + /** + * @return This thing's amount/size + */ + @NotNull Number amount(); + + /** + * This is called before {@link #setAmount(Number)}. + * If the result is false, setting the name will never be attempted. + * + * @return Whether this supports being set + */ + default boolean supportsAmountChange() { + return false; + } + + /** + * The behaviour for changing this thing's name, if possible. + * If not possible, then {@link #supportsAmountChange()} should return false and this + * may throw an error. + * + * @param amount The name to change + * @throws UnsupportedOperationException If this is impossible + */ + default void setAmount(Number amount) throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + + /** + * @return Whether the amount of this is zero, i.e. empty + */ + default boolean isEmpty() { + return this.amount().intValue() == 0; + } + +} diff --git a/src/main/java/ch/njol/skript/lang/util/common/AnyContains.java b/src/main/java/ch/njol/skript/lang/util/common/AnyContains.java new file mode 100644 index 00000000000..c56472e9b55 --- /dev/null +++ b/src/main/java/ch/njol/skript/lang/util/common/AnyContains.java @@ -0,0 +1,48 @@ +package ch.njol.skript.lang.util.common; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.UnknownNullability; + +/** + * A provider for anything that contains other things. + * Anything implementing this (or convertible to this) can be used by the {@link ch.njol.skript.conditions.CondContains} + * conditions. + * + * @see AnyProvider + */ +@FunctionalInterface +public interface AnyContains extends AnyProvider { + + /** + * If {@link #isSafeToCheck(Object)} returns false, values will not be passed to this + * method and will instead return false. + *
+ * The null-ness of the parameter depends on whether {@link #isSafeToCheck(Object)} permits null values. + * + * @param value The value to test + * @return Whether this contains {@code value} + */ + boolean contains(@UnknownNullability Type value); + + /** + * Objects are checked versus this before being cast for {@link #contains(Object)}. + * If your contains method doesn't accept all objects (e.g. for a {@link java.util.List#contains(Object)} call) + * then it can exclude unwanted types (or null values) here. + * + * @param value The value to check + * @return Whether the value is safe to call {@link #contains(Object)} with + */ + default boolean isSafeToCheck(Object value) { + return true; + } + + /** + * The internal method used to verify an object and then check its container. + */ + @ApiStatus.Internal + default boolean checkSafely(Object value) { + //noinspection unchecked + return this.isSafeToCheck(value) && this.contains((Type) value); + } + +} diff --git a/src/main/java/ch/njol/skript/lang/util/common/AnyNamed.java b/src/main/java/ch/njol/skript/lang/util/common/AnyNamed.java new file mode 100644 index 00000000000..4da763d229d --- /dev/null +++ b/src/main/java/ch/njol/skript/lang/util/common/AnyNamed.java @@ -0,0 +1,42 @@ +package ch.njol.skript.lang.util.common; + +import org.jetbrains.annotations.UnknownNullability; + +/** + * A provider for anything with a (text) name. + * Anything implementing this (or convertible to this) can be used by the {@link ch.njol.skript.expressions.ExprName} + * property expression. + * + * @see AnyProvider + */ +@FunctionalInterface +public interface AnyNamed extends AnyProvider { + + /** + * @return This thing's name + */ + @UnknownNullability String name(); + + /** + * This is called before {@link #setName(String)}. + * If the result is false, setting the name will never be attempted. + * + * @return Whether this supports being set + */ + default boolean supportsNameChange() { + return false; + } + + /** + * The behaviour for changing this thing's name, if possible. + * If not possible, then {@link #supportsNameChange()} should return false and this + * may throw an error. + * + * @param name The name to change + * @throws UnsupportedOperationException If this is impossible + */ + default void setName(String name) throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/main/java/ch/njol/skript/lang/util/common/AnyProvider.java b/src/main/java/ch/njol/skript/lang/util/common/AnyProvider.java new file mode 100644 index 00000000000..110a96ce810 --- /dev/null +++ b/src/main/java/ch/njol/skript/lang/util/common/AnyProvider.java @@ -0,0 +1,28 @@ +package ch.njol.skript.lang.util.common; + +/** + * 'AnyProvider' types are holders for common properties (e.g. name, size) where + * it is highly likely that things other than Skript may wish to register + * exponents of the property. + *
+ *
+ * If possible, types should implement an {@link AnyProvider} subtype directly for + * the best possible parsing efficiency. + * However, implementing the interface may not be possible if: + *
    + *
  • registering an existing class from a third-party library
  • + *
  • the subtype getter method conflicts with the type's own methods + * or erasure
  • + *
  • the presence of the supertype might confuse the class's design
  • + *
+ * In these cases, a converter from the class to the AnyX type can be registered. + * The converter should not permit right-chaining or unsafe casts. + *
+ *
+ * The root provider supertype cannot include its own common methods, since these + * may conflict between things that provide two values (e.g. something declaring + * both a name and a size) + */ +public interface AnyProvider { + +} diff --git a/src/main/java/ch/njol/skript/localization/Adjective.java b/src/main/java/ch/njol/skript/localization/Adjective.java index 71e54804548..56c2a9f771e 100644 --- a/src/main/java/ch/njol/skript/localization/Adjective.java +++ b/src/main/java/ch/njol/skript/localization/Adjective.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import java.util.HashMap; diff --git a/src/main/java/ch/njol/skript/localization/ArgsMessage.java b/src/main/java/ch/njol/skript/localization/ArgsMessage.java index 786cf135fce..21e4f739281 100644 --- a/src/main/java/ch/njol/skript/localization/ArgsMessage.java +++ b/src/main/java/ch/njol/skript/localization/ArgsMessage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import java.util.IllegalFormatException; diff --git a/src/main/java/ch/njol/skript/localization/FormattedMessage.java b/src/main/java/ch/njol/skript/localization/FormattedMessage.java index 601cd5ff9aa..f9cb2c88251 100644 --- a/src/main/java/ch/njol/skript/localization/FormattedMessage.java +++ b/src/main/java/ch/njol/skript/localization/FormattedMessage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import java.util.IllegalFormatException; diff --git a/src/main/java/ch/njol/skript/localization/GeneralWords.java b/src/main/java/ch/njol/skript/localization/GeneralWords.java index 219a91b756b..f4d7679f229 100644 --- a/src/main/java/ch/njol/skript/localization/GeneralWords.java +++ b/src/main/java/ch/njol/skript/localization/GeneralWords.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; /** diff --git a/src/main/java/ch/njol/skript/localization/Language.java b/src/main/java/ch/njol/skript/localization/Language.java index d6fdf217b7a..e31567c8377 100644 --- a/src/main/java/ch/njol/skript/localization/Language.java +++ b/src/main/java/ch/njol/skript/localization/Language.java @@ -1,29 +1,12 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import ch.njol.skript.Skript; -import ch.njol.skript.SkriptAddon; import ch.njol.skript.config.Config; import ch.njol.skript.util.ExceptionUtils; import ch.njol.skript.util.FileUtils; import ch.njol.skript.util.Version; +import org.skriptlang.skript.addon.SkriptAddon; +import org.skriptlang.skript.localization.Localizer; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.Nullable; @@ -64,7 +47,7 @@ public class Language { @Nullable private static HashMap localizedLanguage = null; - private static final HashMap langVersion = new HashMap<>(); + private static final HashMap langVersion = new HashMap<>(); public static String getName() { return name; @@ -183,46 +166,80 @@ public static boolean isInitialized() { return !defaultLanguage.isEmpty(); } + @Nullable + private static String getSanitizedLanguageDirectory(SkriptAddon addon) { + Localizer localizer = addon.localizer(); + if (localizer == null) { + return null; + } + String languageFileDirectory = localizer.languageFileDirectory(); + if (languageFileDirectory == null) { + return null; + } + // sanitization + languageFileDirectory = languageFileDirectory.replace('\\', '/'); + if (languageFileDirectory.startsWith("/")) { + languageFileDirectory = languageFileDirectory.substring(1); + } + if (languageFileDirectory.endsWith("/")) { + languageFileDirectory = languageFileDirectory.substring(0, languageFileDirectory.length() - 1); + } + return languageFileDirectory; + } + public static void loadDefault(SkriptAddon addon) { - if (addon.getLanguageFileDirectory() == null) + String languageFileDirectory = getSanitizedLanguageDirectory(addon); + if (languageFileDirectory == null) { return; + } - InputStream defaultIs = addon.plugin.getResource(addon.getLanguageFileDirectory() + "/default.lang"); - InputStream englishIs = addon.plugin.getResource(addon.getLanguageFileDirectory() + "/english.lang"); + Class source = addon.source(); + assert source != null; // getSanitizedLanguageDirectory call means source should not be null + try ( + InputStream defaultIs = source.getResourceAsStream("/" + languageFileDirectory + "/default.lang"); + InputStream englishIs = source.getResourceAsStream("/" + languageFileDirectory + "/english.lang") + ) { - if (defaultIs == null) { - if (englishIs == null) { - throw new IllegalStateException(addon + " is missing the required default.lang file!"); - } else { - defaultIs = englishIs; - englishIs = null; + InputStream defaultLangIs = defaultIs; + InputStream englishLangIs = englishIs; + if (defaultLangIs == null) { + if (englishLangIs == null) { + throw new IllegalStateException(addon + " is missing the required default.lang file!"); + } else { + defaultLangIs = englishLangIs; + englishLangIs = null; + } } - } - HashMap def = load(defaultIs, "default", false); - HashMap en = load(englishIs, "english", addon == Skript.getAddonInstance()); - String v = def.get("version"); - if (v == null) - Skript.warning("Missing version in default.lang"); + Map def = load(defaultLangIs, "default", false); + Map en = load(englishLangIs, "english", addon instanceof org.skriptlang.skript.Skript); - langVersion.put(addon.plugin, v == null ? Skript.getVersion() : new Version(v)); - def.remove("version"); - defaultLanguage.putAll(def); + String v = def.get("version"); + if (v == null) + Skript.warning("Missing version in default.lang"); - if (localizedLanguage == null) - localizedLanguage = new HashMap<>(); - localizedLanguage.putAll(en); + langVersion.put(addon.name(), v == null ? Skript.getVersion() : new Version(v)); + def.remove("version"); + defaultLanguage.putAll(def); - for (LanguageChangeListener l : listeners) - l.onLanguageChange(); + if (localizedLanguage == null) + localizedLanguage = new HashMap<>(); + localizedLanguage.putAll(en); + + for (LanguageChangeListener l : listeners) + l.onLanguageChange(); + + } catch (IOException e) { + throw new RuntimeException(e); + } } public static boolean load(String name) { name = "" + name.toLowerCase(Locale.ENGLISH); localizedLanguage = new HashMap<>(); - boolean exists = load(Skript.getAddonInstance(), name, true); - for (SkriptAddon addon : Skript.getAddons()) { + boolean exists = load(Skript.instance(), name, true); + for (SkriptAddon addon : Skript.instance().addons()) { exists |= load(addon, name, false); } if (!exists) { @@ -243,20 +260,42 @@ public static boolean load(String name) { } private static boolean load(SkriptAddon addon, String name, boolean tryUpdate) { - if (addon.getLanguageFileDirectory() == null) + String languageFileDirectory = getSanitizedLanguageDirectory(addon); + if (languageFileDirectory == null) { return false; + } + + Class source = addon.source(); + // Backwards addon compatibility - if (name.equals("english") && addon.plugin.getResource(addon.getLanguageFileDirectory() + "/default.lang") == null) - return true; + if (name.equals("english")) { + try (InputStream is = source.getResourceAsStream("/" + languageFileDirectory + "/default.lang")) { + if (is == null) { + return true; + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } - HashMap l = load(addon.plugin.getResource(addon.getLanguageFileDirectory() + "/" + name + ".lang"), name, tryUpdate); - File file = new File(addon.plugin.getDataFolder(), addon.getLanguageFileDirectory() + File.separator + name + ".lang"); - try { - if (file.exists()) - l.putAll(load(new FileInputStream(file), name, tryUpdate)); - } catch (FileNotFoundException e) { - assert false; + Map l; + try (InputStream is = source.getResourceAsStream("/" + languageFileDirectory + "/" + name + ".lang")) { + l = load(is, name, tryUpdate); + } catch (IOException e) { + throw new RuntimeException(e); + } + + String dataFileDirectory = addon.localizer().dataFileDirectory(); + if (dataFileDirectory != null) { // attempt to load language files from disk + File file = new File(dataFileDirectory, File.separator + name + ".lang"); + try { + if (file.exists()) + l.putAll(load(new FileInputStream(file), name, tryUpdate)); + } catch (FileNotFoundException e) { + assert false; + } } + if (l.isEmpty()) return false; if (!l.containsKey("version")) { @@ -264,7 +303,7 @@ private static boolean load(SkriptAddon addon, String name, boolean tryUpdate) { } else { try { Version v = new Version("" + l.get("version")); - Version lv = langVersion.get(addon.plugin); + Version lv = langVersion.get(addon.name()); assert lv != null; // set in loadDefault() if (v.isSmallerThan(lv)) Skript.warning(addon + "'s language file " + name + ".lang is outdated, some messages will be english."); @@ -290,7 +329,7 @@ private static boolean load(SkriptAddon addon, String name, boolean tryUpdate) { return true; } - private static HashMap load(@Nullable InputStream in, String name, boolean tryUpdate) { + private static Map load(@Nullable InputStream in, String name, boolean tryUpdate) { if (in == null) return new HashMap<>(); diff --git a/src/main/java/ch/njol/skript/localization/LanguageChangeListener.java b/src/main/java/ch/njol/skript/localization/LanguageChangeListener.java index ed9e60ee19c..429a4230e06 100644 --- a/src/main/java/ch/njol/skript/localization/LanguageChangeListener.java +++ b/src/main/java/ch/njol/skript/localization/LanguageChangeListener.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; public interface LanguageChangeListener { diff --git a/src/main/java/ch/njol/skript/localization/Message.java b/src/main/java/ch/njol/skript/localization/Message.java index fe157ba41a5..486ae7033d0 100644 --- a/src/main/java/ch/njol/skript/localization/Message.java +++ b/src/main/java/ch/njol/skript/localization/Message.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/localization/Noun.java b/src/main/java/ch/njol/skript/localization/Noun.java index 7dc4f22ce2b..40b74f289f3 100644 --- a/src/main/java/ch/njol/skript/localization/Noun.java +++ b/src/main/java/ch/njol/skript/localization/Noun.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/localization/PluralizingArgsMessage.java b/src/main/java/ch/njol/skript/localization/PluralizingArgsMessage.java index 7e745b31054..a4bdf7c446d 100644 --- a/src/main/java/ch/njol/skript/localization/PluralizingArgsMessage.java +++ b/src/main/java/ch/njol/skript/localization/PluralizingArgsMessage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import ch.njol.util.StringUtils; diff --git a/src/main/java/ch/njol/skript/localization/RegexMessage.java b/src/main/java/ch/njol/skript/localization/RegexMessage.java index 2f685eab1b4..956de4b2eb1 100644 --- a/src/main/java/ch/njol/skript/localization/RegexMessage.java +++ b/src/main/java/ch/njol/skript/localization/RegexMessage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.localization; import java.util.regex.Matcher; diff --git a/src/main/java/ch/njol/skript/log/BlockingLogHandler.java b/src/main/java/ch/njol/skript/log/BlockingLogHandler.java index 2e93b8e3a4d..9ace55dfa4c 100644 --- a/src/main/java/ch/njol/skript/log/BlockingLogHandler.java +++ b/src/main/java/ch/njol/skript/log/BlockingLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; /** diff --git a/src/main/java/ch/njol/skript/log/BukkitLoggerFilter.java b/src/main/java/ch/njol/skript/log/BukkitLoggerFilter.java index 434a60f4149..03c10c9ec94 100644 --- a/src/main/java/ch/njol/skript/log/BukkitLoggerFilter.java +++ b/src/main/java/ch/njol/skript/log/BukkitLoggerFilter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.logging.Filter; diff --git a/src/main/java/ch/njol/skript/log/CountingLogHandler.java b/src/main/java/ch/njol/skript/log/CountingLogHandler.java index 3e70cb365ee..872f9b36500 100644 --- a/src/main/java/ch/njol/skript/log/CountingLogHandler.java +++ b/src/main/java/ch/njol/skript/log/CountingLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.logging.Level; diff --git a/src/main/java/ch/njol/skript/log/ErrorDescLogHandler.java b/src/main/java/ch/njol/skript/log/ErrorDescLogHandler.java index 40659deb816..f7f0b4d98af 100644 --- a/src/main/java/ch/njol/skript/log/ErrorDescLogHandler.java +++ b/src/main/java/ch/njol/skript/log/ErrorDescLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.logging.Level; diff --git a/src/main/java/ch/njol/skript/log/ErrorQuality.java b/src/main/java/ch/njol/skript/log/ErrorQuality.java index e781b90c740..1232f1a2412 100644 --- a/src/main/java/ch/njol/skript/log/ErrorQuality.java +++ b/src/main/java/ch/njol/skript/log/ErrorQuality.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; /** diff --git a/src/main/java/ch/njol/skript/log/FilteringLogHandler.java b/src/main/java/ch/njol/skript/log/FilteringLogHandler.java index 46c95b202c9..81c81c434bd 100644 --- a/src/main/java/ch/njol/skript/log/FilteringLogHandler.java +++ b/src/main/java/ch/njol/skript/log/FilteringLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.logging.Level; diff --git a/src/main/java/ch/njol/skript/log/HandlerList.java b/src/main/java/ch/njol/skript/log/HandlerList.java index 8da16744523..a67de8c16b7 100644 --- a/src/main/java/ch/njol/skript/log/HandlerList.java +++ b/src/main/java/ch/njol/skript/log/HandlerList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/log/LogEntry.java b/src/main/java/ch/njol/skript/log/LogEntry.java index 074af5a7bec..0fc0bbc78b9 100644 --- a/src/main/java/ch/njol/skript/log/LogEntry.java +++ b/src/main/java/ch/njol/skript/log/LogEntry.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/log/LogHandler.java b/src/main/java/ch/njol/skript/log/LogHandler.java index 09b5a5c9a9c..5a52957857a 100644 --- a/src/main/java/ch/njol/skript/log/LogHandler.java +++ b/src/main/java/ch/njol/skript/log/LogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.io.Closeable; diff --git a/src/main/java/ch/njol/skript/log/ParseLogHandler.java b/src/main/java/ch/njol/skript/log/ParseLogHandler.java index c391b474fc7..a0a740bc611 100644 --- a/src/main/java/ch/njol/skript/log/ParseLogHandler.java +++ b/src/main/java/ch/njol/skript/log/ParseLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/log/RedirectingLogHandler.java b/src/main/java/ch/njol/skript/log/RedirectingLogHandler.java index bc997f0e024..89057f20470 100644 --- a/src/main/java/ch/njol/skript/log/RedirectingLogHandler.java +++ b/src/main/java/ch/njol/skript/log/RedirectingLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ch/njol/skript/log/RetainingLogHandler.java b/src/main/java/ch/njol/skript/log/RetainingLogHandler.java index ddc7c4b4ff9..52a89344e7a 100644 --- a/src/main/java/ch/njol/skript/log/RetainingLogHandler.java +++ b/src/main/java/ch/njol/skript/log/RetainingLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/log/SkriptLogger.java b/src/main/java/ch/njol/skript/log/SkriptLogger.java index 7ccf88e7566..ad4ffdeaf23 100644 --- a/src/main/java/ch/njol/skript/log/SkriptLogger.java +++ b/src/main/java/ch/njol/skript/log/SkriptLogger.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; import java.util.Collection; diff --git a/src/main/java/ch/njol/skript/log/TimingLogHandler.java b/src/main/java/ch/njol/skript/log/TimingLogHandler.java index a42c26d4b4b..d989d27004c 100644 --- a/src/main/java/ch/njol/skript/log/TimingLogHandler.java +++ b/src/main/java/ch/njol/skript/log/TimingLogHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ /** * A {@link LogHandler} that records the time since its creation. diff --git a/src/main/java/ch/njol/skript/log/Verbosity.java b/src/main/java/ch/njol/skript/log/Verbosity.java index 176461cf401..181ce578db0 100644 --- a/src/main/java/ch/njol/skript/log/Verbosity.java +++ b/src/main/java/ch/njol/skript/log/Verbosity.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.log; /** diff --git a/src/main/java/ch/njol/skript/patterns/ChoicePatternElement.java b/src/main/java/ch/njol/skript/patterns/ChoicePatternElement.java index c2d5c392eff..9494a14a521 100644 --- a/src/main/java/ch/njol/skript/patterns/ChoicePatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/ChoicePatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/GroupPatternElement.java b/src/main/java/ch/njol/skript/patterns/GroupPatternElement.java index 42c41f8bcb3..6d2437634a5 100644 --- a/src/main/java/ch/njol/skript/patterns/GroupPatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/GroupPatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/Keyword.java b/src/main/java/ch/njol/skript/patterns/Keyword.java index c4159af547b..b2cd512e294 100644 --- a/src/main/java/ch/njol/skript/patterns/Keyword.java +++ b/src/main/java/ch/njol/skript/patterns/Keyword.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import com.google.common.base.MoreObjects; diff --git a/src/main/java/ch/njol/skript/patterns/LiteralPatternElement.java b/src/main/java/ch/njol/skript/patterns/LiteralPatternElement.java index c4e7d23d9a1..6a18fa9bfa8 100644 --- a/src/main/java/ch/njol/skript/patterns/LiteralPatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/LiteralPatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/MalformedPatternException.java b/src/main/java/ch/njol/skript/patterns/MalformedPatternException.java index 461e995754e..e9260ed907f 100644 --- a/src/main/java/ch/njol/skript/patterns/MalformedPatternException.java +++ b/src/main/java/ch/njol/skript/patterns/MalformedPatternException.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/MatchResult.java b/src/main/java/ch/njol/skript/patterns/MatchResult.java index 819c78f4361..c58e09d0d1d 100644 --- a/src/main/java/ch/njol/skript/patterns/MatchResult.java +++ b/src/main/java/ch/njol/skript/patterns/MatchResult.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/patterns/OptionalPatternElement.java b/src/main/java/ch/njol/skript/patterns/OptionalPatternElement.java index 55c0456d90a..0ce91a75951 100644 --- a/src/main/java/ch/njol/skript/patterns/OptionalPatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/OptionalPatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/ParseTagPatternElement.java b/src/main/java/ch/njol/skript/patterns/ParseTagPatternElement.java index bb53a39b5f7..187129b805a 100644 --- a/src/main/java/ch/njol/skript/patterns/ParseTagPatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/ParseTagPatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/PatternCompiler.java b/src/main/java/ch/njol/skript/patterns/PatternCompiler.java index 36323cf1dc8..dcc9e088c07 100644 --- a/src/main/java/ch/njol/skript/patterns/PatternCompiler.java +++ b/src/main/java/ch/njol/skript/patterns/PatternCompiler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import ch.njol.skript.lang.SkriptParser; diff --git a/src/main/java/ch/njol/skript/patterns/PatternElement.java b/src/main/java/ch/njol/skript/patterns/PatternElement.java index e3a442a1082..c67069b1236 100644 --- a/src/main/java/ch/njol/skript/patterns/PatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/PatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/patterns/RegexPatternElement.java b/src/main/java/ch/njol/skript/patterns/RegexPatternElement.java index 93000db6872..502703dc032 100644 --- a/src/main/java/ch/njol/skript/patterns/RegexPatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/RegexPatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import ch.njol.skript.lang.SkriptParser; diff --git a/src/main/java/ch/njol/skript/patterns/SkriptPattern.java b/src/main/java/ch/njol/skript/patterns/SkriptPattern.java index d57bd5134d1..87079e89c71 100644 --- a/src/main/java/ch/njol/skript/patterns/SkriptPattern.java +++ b/src/main/java/ch/njol/skript/patterns/SkriptPattern.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/patterns/TypePatternElement.java b/src/main/java/ch/njol/skript/patterns/TypePatternElement.java index bef5ad2dce9..7a411e0c8e6 100644 --- a/src/main/java/ch/njol/skript/patterns/TypePatternElement.java +++ b/src/main/java/ch/njol/skript/patterns/TypePatternElement.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.patterns; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/registrations/Classes.java b/src/main/java/ch/njol/skript/registrations/Classes.java index 1f29173fe4e..b3d219a6a81 100644 --- a/src/main/java/ch/njol/skript/registrations/Classes.java +++ b/src/main/java/ch/njol/skript/registrations/Classes.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.registrations; import java.io.ByteArrayInputStream; diff --git a/src/main/java/ch/njol/skript/registrations/Comparators.java b/src/main/java/ch/njol/skript/registrations/Comparators.java index cbc02e90b4b..ea29257da48 100644 --- a/src/main/java/ch/njol/skript/registrations/Comparators.java +++ b/src/main/java/ch/njol/skript/registrations/Comparators.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.registrations; import ch.njol.skript.classes.Comparator; diff --git a/src/main/java/ch/njol/skript/registrations/Converters.java b/src/main/java/ch/njol/skript/registrations/Converters.java index b139ff2b872..0858ef29e09 100644 --- a/src/main/java/ch/njol/skript/registrations/Converters.java +++ b/src/main/java/ch/njol/skript/registrations/Converters.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.registrations; import ch.njol.skript.classes.Converter; diff --git a/src/main/java/ch/njol/skript/registrations/DefaultClasses.java b/src/main/java/ch/njol/skript/registrations/DefaultClasses.java index e5cf895ddd1..54f6842e44b 100644 --- a/src/main/java/ch/njol/skript/registrations/DefaultClasses.java +++ b/src/main/java/ch/njol/skript/registrations/DefaultClasses.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.registrations; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/registrations/Feature.java b/src/main/java/ch/njol/skript/registrations/Feature.java index d683551a7a0..71751e782f1 100644 --- a/src/main/java/ch/njol/skript/registrations/Feature.java +++ b/src/main/java/ch/njol/skript/registrations/Feature.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.registrations; import ch.njol.skript.SkriptAddon; diff --git a/src/main/java/ch/njol/skript/sections/EffSecShoot.java b/src/main/java/ch/njol/skript/sections/EffSecShoot.java new file mode 100644 index 00000000000..61205d5b1d9 --- /dev/null +++ b/src/main/java/ch/njol/skript/sections/EffSecShoot.java @@ -0,0 +1,329 @@ +package ch.njol.skript.sections; + +import ch.njol.skript.Skript; +import ch.njol.skript.config.SectionNode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.entity.EntityData; +import ch.njol.skript.lang.EffectSection; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.Trigger; +import ch.njol.skript.lang.TriggerItem; +import ch.njol.skript.registrations.EventValues; +import ch.njol.skript.util.Direction; +import ch.njol.skript.util.Getter; +import ch.njol.skript.variables.Variables; +import ch.njol.util.Kleenean; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.reflect.Method; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; + +@Name("Shoot") +@Description("Shoots a projectile (or any other entity) from a given entity or location.") +@Examples({ + "shoot arrow from all players at speed 2", + "shoot a pig from all players:", + "\tadd event-entity to {_projectiles::*}" +}) +@Since("INSERT VERSION") +public class EffSecShoot extends EffectSection { + + //TODO: Remove reflect method once 1.19 is no longer supported + + private enum CaseUsage { + NOT_PROJECTILE_NO_TRIGGER { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + return entityData.spawn(location); + } + }, + NOT_PROJECTILE_TRIGGER { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + //noinspection unchecked,rawtypes + entityData.spawn(location, (Consumer) consumer); + return null; + } + }, + PROJECTILE_NO_WORLD_NO_TRIGGER { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + //noinspection unchecked + Projectile projectile = shooter.launchProjectile((Class) type); + set(projectile, entityData); + return projectile; + } + }, + PROJECTILE_NO_WORLD_TRIGGER_BUKKIT { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + return null; + } + }, + PROJECTILE_NO_WORLD_TRIGGER { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + //noinspection unchecked,rawtypes + shooter.launchProjectile((Class) type, vector, (Consumer) consumer); + return null; + } + }, + PROJECTILE_WORLD_NO_TRIGGER { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + Projectile projectile = (Projectile) shooter.getWorld().spawn(location, type); + projectile.setShooter(shooter); + return projectile; + } + }, + PROJECTILE_WORLD_TRIGGER { + @Override + public @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer) { + //noinspection unchecked,rawtypes + shooter.getWorld().spawn(location, type, (Consumer) consumer); + return null; + } + }; + + /** + * Handles spawning the entity/projectile based on the conditions of the effect and the server + * @param entityData The {@link EntityData} to be spawned + * @param shooter The {@link LivingEntity} that is being used to shoot {@code entityData} from + * @param location The {@link Location} to spawn the {@code entityData} if {@code shooter} is not to be used + * @param type The {@link Class} from {@code entityData} used to be spawned if {@code entityData} is not to be used + * @param vector The {@link Vector} to set the vector of the spawned entity from {@code entityData} or {@code type} + * @param consumer The {@link Consumer} to be used when spawning the entity from {@code entityDataa} or {@code type} + * @return The spawned {@link Entity} + */ + public abstract @Nullable Entity shootHandler(EntityData entityData, LivingEntity shooter, Location location, Class type, Vector vector, Consumer consumer); + } + + public static class ShootEvent extends Event { + + private Entity projectile; + private @Nullable LivingEntity shooter; + + public ShootEvent(Entity projectile, @Nullable LivingEntity shooter) { + this.projectile = projectile; + this.shooter = shooter; + } + + public Entity getProjectile() { + return projectile; + } + + public @Nullable LivingEntity getShooter() { + return shooter; + } + + @Override + public @NotNull HandlerList getHandlers() { + throw new IllegalStateException(); + } + } + + private static final boolean RUNNING_PAPER; + private static Method launchWithBukkitConsumer; + + static { + Skript.registerSection(EffSecShoot.class, + "shoot %entitydatas% [from %livingentities/locations%] [(at|with) (speed|velocity) %-number%] [%-direction%]", + "(make|let) %livingentities/locations% shoot %entitydatas% [(at|with) (speed|velocity) %-number%] [%-direction%]" + ); + EventValues.registerEventValue(ShootEvent.class, Entity.class, new Getter() { + @Override + public @Nullable Entity get(ShootEvent shootEvent) { + return shootEvent.getProjectile(); + } + }, EventValues.TIME_NOW); + EventValues.registerEventValue(ShootEvent.class, Projectile.class, new Getter() { + @Override + public @Nullable Projectile get(ShootEvent shootEvent) { + return shootEvent.getProjectile() instanceof Projectile projectile ? projectile : null; + } + }, EventValues.TIME_NOW); + + if (!Skript.isRunningMinecraft(1, 20, 3)) { + try { + launchWithBukkitConsumer = LivingEntity.class.getMethod("launchProjectile", Class.class, Vector.class, org.bukkit.util.Consumer.class); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + boolean launchHasJavaConsumer = Skript.methodExists(LivingEntity.class, "launchProjectile", Class.class, Vector.class, Consumer.class); + RUNNING_PAPER = launchWithBukkitConsumer != null || launchHasJavaConsumer; + } + + private final static Double DEFAULT_SPEED = 5.; + private Expression> types; + private Expression shooters; + private @Nullable Expression velocity; + private @Nullable Expression direction; + public static Entity lastSpawned = null; + private @Nullable Trigger trigger; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult, @Nullable SectionNode sectionNode, @Nullable List triggerItems) { + //noinspection unchecked + types = (Expression>) exprs[matchedPattern]; + shooters = exprs[1 - matchedPattern]; + //noinspection unchecked + velocity = (Expression) exprs[2]; + //noinspection unchecked + direction = (Expression) exprs[3]; + + if (sectionNode != null) { + AtomicBoolean delayed = new AtomicBoolean(false); + Runnable afterLoading = () -> delayed.set(!getParser().getHasDelayBefore().isFalse()); + trigger = loadCode(sectionNode, "shoot", afterLoading, ShootEvent.class); + if (delayed.get()) { + Skript.error("Delays cannot be used within a 'shoot' effect section"); + return false; + } + } + return true; + } + + @Override + protected @Nullable TriggerItem walk(Event event) { + lastSpawned = null; + Number finalVelocity = velocity != null ? velocity.getSingle(event) : DEFAULT_SPEED; + Direction finalDirection = direction != null ? direction.getSingle(event) : Direction.IDENTITY; + if (finalVelocity == null || finalDirection == null) + return null; + EntityData[] data = types.getArray(event); + + for (Object shooter : shooters.getArray(event)) { + for (EntityData entityData : data) { + Entity finalProjectile = null; + Vector vector; + if (shooter instanceof LivingEntity livingShooter) { + vector = finalDirection.getDirection(livingShooter.getLocation()).multiply(finalVelocity.doubleValue()); + //noinspection rawtypes + Consumer afterSpawn = afterSpawn(event, entityData, livingShooter); + Class type = entityData.getType(); + Location shooterLoc = livingShooter.getLocation(); + shooterLoc.setY(shooterLoc.getY() + livingShooter.getEyeHeight() / 2); + boolean isProjectile = false, useWorldSpawn = false; + if (Fireball.class.isAssignableFrom(type)) { + shooterLoc = livingShooter.getEyeLocation().add(vector.clone().normalize().multiply(0.5)); + isProjectile = true; + useWorldSpawn = true; + } else if (Projectile.class.isAssignableFrom(type)) { + isProjectile = true; + if (trigger != null && !RUNNING_PAPER) { + useWorldSpawn = true; + } + } + + CaseUsage caseUsage = getCaseUsage(isProjectile, useWorldSpawn, trigger != null); + if (caseUsage == CaseUsage.PROJECTILE_NO_WORLD_TRIGGER_BUKKIT) { + try { + launchWithBukkitConsumer.invoke(livingShooter, type, vector, afterSpawnBukkit(event, entityData, livingShooter)); + } catch (Exception ignored) {} + } else { + finalProjectile = caseUsage.shootHandler(entityData, livingShooter, shooterLoc, type, vector, afterSpawn); + } + } else { + vector = finalDirection.getDirection((Location) shooter).multiply(finalVelocity.doubleValue()); + if (trigger != null) { + //noinspection unchecked,rawtypes + entityData.spawn((Location) shooter, (Consumer) afterSpawn(event, entityData, null)); + } else { + finalProjectile = entityData.spawn((Location) shooter); + } + } + if (finalProjectile != null) { + finalProjectile.setVelocity(vector); + lastSpawned = finalProjectile; + } + } + } + + return super.walk(event, false); + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "shoot " + types.toString(event, debug) + " from " + shooters.toString(event, debug) + + (velocity != null ? " at speed " + velocity.toString(event, debug) : "") + + (direction != null ? " " + direction.toString(event, debug) : ""); + } + + private static void set(Entity entity, EntityData entityData) { + //noinspection unchecked + entityData.set((E) entity); + } + + private CaseUsage getCaseUsage(Boolean isProjectile, Boolean useWorldSpawn, Boolean hasTrigger) { + if (!isProjectile) { + if (!hasTrigger) + return CaseUsage.NOT_PROJECTILE_NO_TRIGGER; + return CaseUsage.NOT_PROJECTILE_TRIGGER; + } + if (!useWorldSpawn) { + if (!hasTrigger) + return CaseUsage.PROJECTILE_NO_WORLD_NO_TRIGGER; + if (launchWithBukkitConsumer != null) + return CaseUsage.PROJECTILE_NO_WORLD_TRIGGER_BUKKIT; + return CaseUsage.PROJECTILE_NO_WORLD_TRIGGER; + } + if (!hasTrigger) + return CaseUsage.PROJECTILE_WORLD_NO_TRIGGER; + return CaseUsage.PROJECTILE_WORLD_TRIGGER; + } + + private Consumer afterSpawn(Event event, EntityData entityData, @Nullable LivingEntity shooter) { + return entity -> { + if (entity instanceof Fireball fireball) + fireball.setShooter(shooter); + else if (entity instanceof Projectile projectile && shooter != null) { + projectile.setShooter(shooter); + set(projectile, entityData); + } + ShootEvent shootEvent = new ShootEvent(entity, shooter); + lastSpawned = entity; + Variables.setLocalVariables(shootEvent, Variables.copyLocalVariables(event)); + TriggerItem.walk(trigger, shootEvent); + Variables.setLocalVariables(event, Variables.copyLocalVariables(shootEvent)); + Variables.removeLocals(shootEvent); + }; + } + + /** + * MC 1.19 uses Bukkit Consumer for LivingEntity#launchProjectile instead of Java Consumer + */ + @SuppressWarnings("deprecation") + private org.bukkit.util.Consumer afterSpawnBukkit(Event event, EntityData entityData, @Nullable LivingEntity shooter) { + return entity -> { + if (entity instanceof Fireball fireball) + fireball.setShooter(shooter); + else if (entity instanceof Projectile projectile && shooter != null) { + projectile.setShooter(shooter); + set(projectile, entityData); + } + ShootEvent shootEvent = new ShootEvent(entity, shooter); + lastSpawned = entity; + Variables.setLocalVariables(shootEvent, Variables.copyLocalVariables(event)); + TriggerItem.walk(trigger, shootEvent); + Variables.setLocalVariables(event, Variables.copyLocalVariables(shootEvent)); + Variables.removeLocals(shootEvent); + }; + } + +} diff --git a/src/main/java/ch/njol/skript/sections/EffSecSpawn.java b/src/main/java/ch/njol/skript/sections/EffSecSpawn.java index da243abf56b..0b69d528313 100644 --- a/src/main/java/ch/njol/skript/sections/EffSecSpawn.java +++ b/src/main/java/ch/njol/skript/sections/EffSecSpawn.java @@ -1,29 +1,8 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.sections; import ch.njol.skript.Skript; import ch.njol.skript.config.SectionNode; -import ch.njol.skript.doc.Description; -import ch.njol.skript.doc.Examples; -import ch.njol.skript.doc.Name; -import ch.njol.skript.doc.Since; +import ch.njol.skript.doc.*; import ch.njol.skript.entity.EntityType; import ch.njol.skript.lang.EffectSection; import ch.njol.skript.lang.Expression; @@ -37,6 +16,7 @@ import ch.njol.util.Kleenean; import org.bukkit.Location; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntitySnapshot; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -55,7 +35,9 @@ "Do note that other event values, such as 'player', won't work in this section.", "", "If you're spawning a display and want it to be empty on initialization, like not having a block display be stone, " + - "set hidden config node 'spawn empty displays' to true." + "set hidden config node 'spawn empty displays' to true.", + "", + "Note that when spawning an entity via entity snapshots, the code within the section will not run instantaneously as compared to spawning normally (via 'a zombie')." }) @Examples({ "spawn 3 creepers at the targeted block", @@ -66,7 +48,8 @@ "spawn a block display of a ladder[waterlogged=true] at location above player:", "\tset billboard of event-display to center # allows the display to rotate around the center axis" }) -@Since("1.0, 2.6.1 (with section), 2.8.6 (dropped items)") +@RequiredPlugins("Minecraft 1.20.2+ (entity snapshots)") +@Since("1.0, 2.6.1 (with section), 2.8.6 (dropped items), INSERT VERSION (entity snapshots)") public class EffSecSpawn extends EffectSection { public static class SpawnEvent extends Event { @@ -89,9 +72,12 @@ public HandlerList getHandlers() { } static { + String acceptedTypes = "%entitytypes%"; + if (Skript.classExists("org.bukkit.entity.EntitySnapshot")) + acceptedTypes = "%entitytypes/entitysnapshots%"; Skript.registerSection(EffSecSpawn.class, - "(spawn|summon) %entitytypes% [%directions% %locations%]", - "(spawn|summon) %number% of %entitytypes% [%directions% %locations%]" + "(spawn|summon) " + acceptedTypes + " [%directions% %locations%]", + "(spawn|summon) %number% of " + acceptedTypes + " [%directions% %locations%]" ); EventValues.registerEventValue(SpawnEvent.class, Entity.class, new Getter() { @Override @@ -103,7 +89,7 @@ public Entity get(SpawnEvent event) { private Expression locations; - private Expression types; + private Expression types; @Nullable private Expression amount; @@ -120,7 +106,7 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Nullable SectionNode sectionNode, @Nullable List triggerItems) { amount = matchedPattern == 0 ? null : (Expression) (exprs[0]); - types = (Expression) exprs[matchedPattern]; + types = exprs[matchedPattern]; locations = Direction.combine((Expression) exprs[1 + matchedPattern], (Expression) exprs[2 + matchedPattern]); if (sectionNode != null) { @@ -153,16 +139,28 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye Number numberAmount = amount != null ? amount.getSingle(event) : 1; if (numberAmount != null) { double amount = numberAmount.doubleValue(); - EntityType[] types = this.types.getArray(event); + Object[] types = this.types.getArray(event); for (Location location : locations.getArray(event)) { - for (EntityType type : types) { - double typeAmount = amount * type.getAmount(); - for (int i = 0; i < typeAmount; i++) { - if (consumer != null) { - //noinspection unchecked,rawtypes - type.data.spawn(location, (Consumer) consumer); // lastSpawned set within Consumer - } else { - lastSpawned = type.data.spawn(location); + for (Object type : types) { + if (type instanceof EntityType entityType) { + double typeAmount = amount * entityType.getAmount(); + for (int i = 0; i < typeAmount; i++) { + if (consumer != null) { + //noinspection unchecked,rawtypes + entityType.data.spawn(location, (Consumer) consumer); // lastSpawned set within Consumer + } else { + lastSpawned = entityType.data.spawn(location); + } + } + } else if (type instanceof EntitySnapshot snapshot) { + for (int i = 0; i < amount; i++) { + Entity entity = snapshot.createEntity(location); + if (consumer != null) { + //noinspection unchecked + ((Consumer) consumer).accept(entity); + } else { + lastSpawned = entity; + } } } } diff --git a/src/main/java/ch/njol/skript/sections/SecFor.java b/src/main/java/ch/njol/skript/sections/SecFor.java index 575accc07b9..9fe0e2dbab5 100644 --- a/src/main/java/ch/njol/skript/sections/SecFor.java +++ b/src/main/java/ch/njol/skript/sections/SecFor.java @@ -45,7 +45,7 @@ When looping a simple (non-indexed) set of values, e.g. all players, the index w "loop key {_index} and value {_value} in {list of items::*}:", "\tbroadcast \"%{_index}% = %{_value}%\"", "", - "for each {_index} = {_value} in {my list::*}:", + "for each {_index}, {_value} in {my list::*}:", "\tbroadcast \"%{_index}% = %{_value}%\"", }) @Since("INSERT VERSION") diff --git a/src/main/java/ch/njol/skript/sections/SecWhile.java b/src/main/java/ch/njol/skript/sections/SecWhile.java index 25e295c56ac..18626490ee3 100644 --- a/src/main/java/ch/njol/skript/sections/SecWhile.java +++ b/src/main/java/ch/njol/skript/sections/SecWhile.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.sections; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/structures/StructAliases.java b/src/main/java/ch/njol/skript/structures/StructAliases.java index 37d26581734..861b24bcc40 100644 --- a/src/main/java/ch/njol/skript/structures/StructAliases.java +++ b/src/main/java/ch/njol/skript/structures/StructAliases.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/structures/StructCommand.java b/src/main/java/ch/njol/skript/structures/StructCommand.java index 1b148bd624a..5c2ccbb89eb 100644 --- a/src/main/java/ch/njol/skript/structures/StructCommand.java +++ b/src/main/java/ch/njol/skript/structures/StructCommand.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/structures/StructEvent.java b/src/main/java/ch/njol/skript/structures/StructEvent.java index 83c24d791c8..5033a0be5fa 100644 --- a/src/main/java/ch/njol/skript/structures/StructEvent.java +++ b/src/main/java/ch/njol/skript/structures/StructEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/structures/StructFunction.java b/src/main/java/ch/njol/skript/structures/StructFunction.java index ec9feba732a..1a8ea11c478 100644 --- a/src/main/java/ch/njol/skript/structures/StructFunction.java +++ b/src/main/java/ch/njol/skript/structures/StructFunction.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/ch/njol/skript/structures/StructOptions.java b/src/main/java/ch/njol/skript/structures/StructOptions.java index df20ff0b4ee..2224a7b1641 100644 --- a/src/main/java/ch/njol/skript/structures/StructOptions.java +++ b/src/main/java/ch/njol/skript/structures/StructOptions.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/structures/StructUsing.java b/src/main/java/ch/njol/skript/structures/StructUsing.java index 2ab5ace28fa..d1dae4f2e76 100644 --- a/src/main/java/ch/njol/skript/structures/StructUsing.java +++ b/src/main/java/ch/njol/skript/structures/StructUsing.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/structures/StructVariables.java b/src/main/java/ch/njol/skript/structures/StructVariables.java index 8579dc2386f..1d8f818c514 100644 --- a/src/main/java/ch/njol/skript/structures/StructVariables.java +++ b/src/main/java/ch/njol/skript/structures/StructVariables.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.structures; import java.util.ArrayDeque; diff --git a/src/main/java/ch/njol/skript/test/platform/Environment.java b/src/main/java/ch/njol/skript/test/platform/Environment.java index bbe2dc52ceb..907265db2e1 100644 --- a/src/main/java/ch/njol/skript/test/platform/Environment.java +++ b/src/main/java/ch/njol/skript/test/platform/Environment.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.platform; import com.google.gson.Gson; diff --git a/src/main/java/ch/njol/skript/test/platform/PlatformMain.java b/src/main/java/ch/njol/skript/test/platform/PlatformMain.java index ab72df70985..744caa675b3 100644 --- a/src/main/java/ch/njol/skript/test/platform/PlatformMain.java +++ b/src/main/java/ch/njol/skript/test/platform/PlatformMain.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.platform; import ch.njol.skript.test.utils.TestResults; diff --git a/src/main/java/ch/njol/skript/test/runner/CondMethodExists.java b/src/main/java/ch/njol/skript/test/runner/CondMethodExists.java index 3af79ec490d..b91d320a7c1 100644 --- a/src/main/java/ch/njol/skript/test/runner/CondMethodExists.java +++ b/src/main/java/ch/njol/skript/test/runner/CondMethodExists.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.conditions.base.PropertyCondition; diff --git a/src/main/java/ch/njol/skript/test/runner/CondRunningJUnit.java b/src/main/java/ch/njol/skript/test/runner/CondRunningJUnit.java index 399e144b09d..7df24949ab5 100644 --- a/src/main/java/ch/njol/skript/test/runner/CondRunningJUnit.java +++ b/src/main/java/ch/njol/skript/test/runner/CondRunningJUnit.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/test/runner/EffAssert.java b/src/main/java/ch/njol/skript/test/runner/EffAssert.java index d414980e282..511c2e92dd9 100644 --- a/src/main/java/ch/njol/skript/test/runner/EffAssert.java +++ b/src/main/java/ch/njol/skript/test/runner/EffAssert.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.conditions.CondCompare; diff --git a/src/main/java/ch/njol/skript/test/runner/EffDebug.java b/src/main/java/ch/njol/skript/test/runner/EffDebug.java index 41a533a2fca..0ac98a60be9 100644 --- a/src/main/java/ch/njol/skript/test/runner/EffDebug.java +++ b/src/main/java/ch/njol/skript/test/runner/EffDebug.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/test/runner/EffObjectives.java b/src/main/java/ch/njol/skript/test/runner/EffObjectives.java index 7134b2e3639..79d0a5e675b 100644 --- a/src/main/java/ch/njol/skript/test/runner/EffObjectives.java +++ b/src/main/java/ch/njol/skript/test/runner/EffObjectives.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/test/runner/EffTestPluralClassInfos.java b/src/main/java/ch/njol/skript/test/runner/EffTestPluralClassInfos.java new file mode 100644 index 00000000000..1a73ba5cdff --- /dev/null +++ b/src/main/java/ch/njol/skript/test/runner/EffTestPluralClassInfos.java @@ -0,0 +1,70 @@ +package ch.njol.skript.test.runner; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.ClassInfo; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.NoDoc; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.registrations.Classes; +import ch.njol.util.Kleenean; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +/** + * This class is used to test whether class-info plurals are detected successfully. + * The syntax in it should never be parsed or used (even in test mode) + * and does nothing. + */ +@Name("Test Plural Class Infos") +@Description("Tests that plural class infos are identified correctly.") +@NoDoc +public class EffTestPluralClassInfos extends Effect { + + static { + class Example1 {} + class Example2 {} + class Example3 {} + class Example4 {} + if (TestMode.ENABLED) { + Classes.registerClass(new ClassInfo<>(Example1.class, "testgui") + .user("example1") + .name("Test -ui")); + Classes.registerClass(new ClassInfo<>(Example2.class, "exemplus") + .user("example2") + .name("Test -i")); + Classes.registerClass(new ClassInfo<>(Example3.class, "aardwolf") + .user("example3") + .name("Test -ves")); + Classes.registerClass(new ClassInfo<>(Example4.class, "hoof") + .user("example3") + .name("Test -ves 2")); + Skript.registerEffect(EffTestPluralClassInfos.class, + "classinfo test for %testgui%", + "classinfo test for %testguis%", + "classinfo test for %exemplus%", + "classinfo test for %exempli%", + "classinfo test for %aardwolf%", + "classinfo test for %aardwolves%", + "classinfo test for %hoof%", + "classinfo test for %hooves%"); + } + } + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + return false; + } + + @Override + protected void execute(Event event) { + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return ""; + } + +} diff --git a/src/main/java/ch/njol/skript/test/runner/ExprExperimentalOnly.java b/src/main/java/ch/njol/skript/test/runner/ExprExperimentalOnly.java index 40d7e48af03..b9dd57b69af 100644 --- a/src/main/java/ch/njol/skript/test/runner/ExprExperimentalOnly.java +++ b/src/main/java/ch/njol/skript/test/runner/ExprExperimentalOnly.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/test/runner/ExprParseLogs.java b/src/main/java/ch/njol/skript/test/runner/ExprParseLogs.java index 7f5e8c7151b..fbacc5a2000 100644 --- a/src/main/java/ch/njol/skript/test/runner/ExprParseLogs.java +++ b/src/main/java/ch/njol/skript/test/runner/ExprParseLogs.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/test/runner/ExprTestStringLiteral.java b/src/main/java/ch/njol/skript/test/runner/ExprTestStringLiteral.java index aedd7ef5a7f..48dd44588f7 100644 --- a/src/main/java/ch/njol/skript/test/runner/ExprTestStringLiteral.java +++ b/src/main/java/ch/njol/skript/test/runner/ExprTestStringLiteral.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/test/runner/SecParse.java b/src/main/java/ch/njol/skript/test/runner/SecParse.java index 8a890dbcfa7..f01d5029103 100644 --- a/src/main/java/ch/njol/skript/test/runner/SecParse.java +++ b/src/main/java/ch/njol/skript/test/runner/SecParse.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/test/runner/SecReturnable.java b/src/main/java/ch/njol/skript/test/runner/SecReturnable.java index 03833d7132d..b06c82a56ae 100644 --- a/src/main/java/ch/njol/skript/test/runner/SecReturnable.java +++ b/src/main/java/ch/njol/skript/test/runner/SecReturnable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/test/runner/SkriptJUnitTest.java b/src/main/java/ch/njol/skript/test/runner/SkriptJUnitTest.java index 6988d537cff..69f2c656218 100644 --- a/src/main/java/ch/njol/skript/test/runner/SkriptJUnitTest.java +++ b/src/main/java/ch/njol/skript/test/runner/SkriptJUnitTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/test/runner/SkriptTestEvent.java b/src/main/java/ch/njol/skript/test/runner/SkriptTestEvent.java index 558a7ae458e..daedf8e2286 100644 --- a/src/main/java/ch/njol/skript/test/runner/SkriptTestEvent.java +++ b/src/main/java/ch/njol/skript/test/runner/SkriptTestEvent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import org.bukkit.event.Event; diff --git a/src/main/java/ch/njol/skript/test/runner/StructEntryContainerTest.java b/src/main/java/ch/njol/skript/test/runner/StructEntryContainerTest.java new file mode 100644 index 00000000000..14ce4770544 --- /dev/null +++ b/src/main/java/ch/njol/skript/test/runner/StructEntryContainerTest.java @@ -0,0 +1,67 @@ +package ch.njol.skript.test.runner; + +import ch.njol.skript.ScriptLoader; +import ch.njol.skript.Skript; +import ch.njol.skript.config.SectionNode; +import ch.njol.skript.lang.Literal; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.Trigger; +import ch.njol.skript.lang.TriggerItem; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.lang.entry.EntryContainer; +import org.skriptlang.skript.lang.entry.EntryValidator; +import org.skriptlang.skript.lang.script.Script; +import org.skriptlang.skript.lang.structure.Structure; + +import java.util.List; + +public class StructEntryContainerTest extends Structure { + + public static class TestEvent extends Event { + @Override + public @NotNull HandlerList getHandlers() { + throw new IllegalStateException(); + } + } + + static { + if (TestMode.ENABLED) + Skript.registerStructure(StructEntryContainerTest.class, + EntryValidator.builder() + .addSection("has entry", true) + .build(), + "test entry container"); + } + + private EntryContainer entryContainer; + + @Override + public boolean init(Literal[] args, int matchedPattern, ParseResult parseResult, @Nullable EntryContainer entryContainer) { + assert entryContainer != null; + this.entryContainer = entryContainer; + if (entryContainer.hasEntry("has entry")) { + return true; + } + assert false; + return false; + } + + @Override + public boolean load() { + SectionNode section = entryContainer.get("has entry", SectionNode.class, false); + List triggerItems = ScriptLoader.loadItems(section); + Script script = getParser().getCurrentScript(); + Trigger trigger = new Trigger(script, "entry container test", null, triggerItems); + trigger.execute(new TestEvent()); + return true; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "test entry container"; + } + +} diff --git a/src/main/java/ch/njol/skript/test/runner/TestFeatures.java b/src/main/java/ch/njol/skript/test/runner/TestFeatures.java index b975ff219f9..e42fcdb5d81 100644 --- a/src/main/java/ch/njol/skript/test/runner/TestFeatures.java +++ b/src/main/java/ch/njol/skript/test/runner/TestFeatures.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/test/runner/TestFunctions.java b/src/main/java/ch/njol/skript/test/runner/TestFunctions.java index fe9a434cebe..0c5650048ea 100644 --- a/src/main/java/ch/njol/skript/test/runner/TestFunctions.java +++ b/src/main/java/ch/njol/skript/test/runner/TestFunctions.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import ch.njol.skript.classes.ClassInfo; diff --git a/src/main/java/ch/njol/skript/test/runner/TestMode.java b/src/main/java/ch/njol/skript/test/runner/TestMode.java index fdebc5c57e1..7d01b75764c 100644 --- a/src/main/java/ch/njol/skript/test/runner/TestMode.java +++ b/src/main/java/ch/njol/skript/test/runner/TestMode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import java.io.File; diff --git a/src/main/java/ch/njol/skript/test/runner/TestTracker.java b/src/main/java/ch/njol/skript/test/runner/TestTracker.java index 152b7841eb9..f63c9ea6065 100644 --- a/src/main/java/ch/njol/skript/test/runner/TestTracker.java +++ b/src/main/java/ch/njol/skript/test/runner/TestTracker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.runner; import java.io.File; diff --git a/src/main/java/ch/njol/skript/test/utils/TestResults.java b/src/main/java/ch/njol/skript/test/utils/TestResults.java index d8e9c036538..b6246148f50 100644 --- a/src/main/java/ch/njol/skript/test/utils/TestResults.java +++ b/src/main/java/ch/njol/skript/test/utils/TestResults.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.test.utils; import java.util.Map; @@ -63,10 +45,10 @@ public boolean docsFailed() { public String createReport() { StringBuilder sb = new StringBuilder("Succeeded:\n"); for (String test : succeeded) - sb.append(test).append('\n'); - sb.append("Failed:\n"); + sb.append("").append(test).append('\n'); + sb.append("Failed:\n"); for (Map.Entry entry : failed.entrySet()) - sb.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n'); + sb.append("").append(entry.getKey()).append(": ").append(entry.getValue()).append('\n'); return sb.toString(); } diff --git a/src/main/java/ch/njol/skript/timings/SkriptTimings.java b/src/main/java/ch/njol/skript/timings/SkriptTimings.java index b6605df80d4..a79aef31dd4 100644 --- a/src/main/java/ch/njol/skript/timings/SkriptTimings.java +++ b/src/main/java/ch/njol/skript/timings/SkriptTimings.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.timings; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/update/GithubChecker.java b/src/main/java/ch/njol/skript/update/GithubChecker.java index ec53db32726..de844d455e1 100644 --- a/src/main/java/ch/njol/skript/update/GithubChecker.java +++ b/src/main/java/ch/njol/skript/update/GithubChecker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/update/NoUpdateChecker.java b/src/main/java/ch/njol/skript/update/NoUpdateChecker.java index d65f5ab09bb..acaae92f9f4 100644 --- a/src/main/java/ch/njol/skript/update/NoUpdateChecker.java +++ b/src/main/java/ch/njol/skript/update/NoUpdateChecker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/ch/njol/skript/update/ReleaseChannel.java b/src/main/java/ch/njol/skript/update/ReleaseChannel.java index e0c8ef5af12..caf7ca04651 100644 --- a/src/main/java/ch/njol/skript/update/ReleaseChannel.java +++ b/src/main/java/ch/njol/skript/update/ReleaseChannel.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.util.function.Function; diff --git a/src/main/java/ch/njol/skript/update/ReleaseManifest.java b/src/main/java/ch/njol/skript/update/ReleaseManifest.java index e1fe7737476..160a743e6ae 100644 --- a/src/main/java/ch/njol/skript/update/ReleaseManifest.java +++ b/src/main/java/ch/njol/skript/update/ReleaseManifest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.lang.reflect.InvocationTargetException; diff --git a/src/main/java/ch/njol/skript/update/ReleaseStatus.java b/src/main/java/ch/njol/skript/update/ReleaseStatus.java index 72838333a35..1f2a24fa32a 100644 --- a/src/main/java/ch/njol/skript/update/ReleaseStatus.java +++ b/src/main/java/ch/njol/skript/update/ReleaseStatus.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; diff --git a/src/main/java/ch/njol/skript/update/UpdateChecker.java b/src/main/java/ch/njol/skript/update/UpdateChecker.java index 5ae8df62708..e737db2861c 100644 --- a/src/main/java/ch/njol/skript/update/UpdateChecker.java +++ b/src/main/java/ch/njol/skript/update/UpdateChecker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/ch/njol/skript/update/UpdateManifest.java b/src/main/java/ch/njol/skript/update/UpdateManifest.java index 1c105ae246a..e44e056c87f 100644 --- a/src/main/java/ch/njol/skript/update/UpdateManifest.java +++ b/src/main/java/ch/njol/skript/update/UpdateManifest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.net.URL; diff --git a/src/main/java/ch/njol/skript/update/Updater.java b/src/main/java/ch/njol/skript/update/Updater.java index 4f96cff424b..2922dacc98d 100644 --- a/src/main/java/ch/njol/skript/update/Updater.java +++ b/src/main/java/ch/njol/skript/update/Updater.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/ch/njol/skript/update/UpdaterState.java b/src/main/java/ch/njol/skript/update/UpdaterState.java index 22682d8401c..982df2e57c3 100644 --- a/src/main/java/ch/njol/skript/update/UpdaterState.java +++ b/src/main/java/ch/njol/skript/update/UpdaterState.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.update; diff --git a/src/main/java/ch/njol/skript/util/AABB.java b/src/main/java/ch/njol/skript/util/AABB.java index 6e5dec1ce20..87a6e09fa2b 100644 --- a/src/main/java/ch/njol/skript/util/AABB.java +++ b/src/main/java/ch/njol/skript/util/AABB.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.Iterator; diff --git a/src/main/java/ch/njol/skript/util/AsyncEffect.java b/src/main/java/ch/njol/skript/util/AsyncEffect.java index ae124fa0401..7786185f1ea 100644 --- a/src/main/java/ch/njol/skript/util/AsyncEffect.java +++ b/src/main/java/ch/njol/skript/util/AsyncEffect.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import org.bukkit.Bukkit; diff --git a/src/main/java/ch/njol/skript/util/BlockInventoryHolder.java b/src/main/java/ch/njol/skript/util/BlockInventoryHolder.java index a9d79945b02..9fc9ce71b04 100644 --- a/src/main/java/ch/njol/skript/util/BlockInventoryHolder.java +++ b/src/main/java/ch/njol/skript/util/BlockInventoryHolder.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import org.bukkit.block.BlockState; diff --git a/src/main/java/ch/njol/skript/util/BlockSphereIterator.java b/src/main/java/ch/njol/skript/util/BlockSphereIterator.java index 9a4bf5ab5b7..f65ad6159c2 100644 --- a/src/main/java/ch/njol/skript/util/BlockSphereIterator.java +++ b/src/main/java/ch/njol/skript/util/BlockSphereIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import org.bukkit.Location; diff --git a/src/main/java/ch/njol/skript/util/BlockStateBlock.java b/src/main/java/ch/njol/skript/util/BlockStateBlock.java index 364ae09229c..73bb86e1384 100644 --- a/src/main/java/ch/njol/skript/util/BlockStateBlock.java +++ b/src/main/java/ch/njol/skript/util/BlockStateBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/util/BlockUtils.java b/src/main/java/ch/njol/skript/util/BlockUtils.java index 1768fd5b4f6..213789e9251 100644 --- a/src/main/java/ch/njol/skript/util/BlockUtils.java +++ b/src/main/java/ch/njol/skript/util/BlockUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/util/ClassInfoReference.java b/src/main/java/ch/njol/skript/util/ClassInfoReference.java index a5bf0720859..a0bec2dd74e 100644 --- a/src/main/java/ch/njol/skript/util/ClassInfoReference.java +++ b/src/main/java/ch/njol/skript/util/ClassInfoReference.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.classes.ClassInfo; diff --git a/src/main/java/ch/njol/skript/util/Color.java b/src/main/java/ch/njol/skript/util/Color.java index 127e809652f..3b3a7c02471 100644 --- a/src/main/java/ch/njol/skript/util/Color.java +++ b/src/main/java/ch/njol/skript/util/Color.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.yggdrasil.YggdrasilSerializable.YggdrasilExtendedSerializable; diff --git a/src/main/java/ch/njol/skript/util/Container.java b/src/main/java/ch/njol/skript/util/Container.java index f2efa3025dd..ae62726bf3b 100644 --- a/src/main/java/ch/njol/skript/util/Container.java +++ b/src/main/java/ch/njol/skript/util/Container.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/skript/util/Contract.java b/src/main/java/ch/njol/skript/util/Contract.java index 6995ddf9f65..c4984bad339 100644 --- a/src/main/java/ch/njol/skript/util/Contract.java +++ b/src/main/java/ch/njol/skript/util/Contract.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/util/Date.java b/src/main/java/ch/njol/skript/util/Date.java index 85df22cb927..b37f9f037cf 100644 --- a/src/main/java/ch/njol/skript/util/Date.java +++ b/src/main/java/ch/njol/skript/util/Date.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.TimeZone; diff --git a/src/main/java/ch/njol/skript/util/DelayedChangeBlock.java b/src/main/java/ch/njol/skript/util/DelayedChangeBlock.java index 6951a787c93..e202c4911a6 100644 --- a/src/main/java/ch/njol/skript/util/DelayedChangeBlock.java +++ b/src/main/java/ch/njol/skript/util/DelayedChangeBlock.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/util/Direction.java b/src/main/java/ch/njol/skript/util/Direction.java index 50b9aca87c0..d2f8e8fdf8c 100644 --- a/src/main/java/ch/njol/skript/util/Direction.java +++ b/src/main/java/ch/njol/skript/util/Direction.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/ch/njol/skript/util/EmptyStacktraceException.java b/src/main/java/ch/njol/skript/util/EmptyStacktraceException.java index b25f19a6206..69d4b82ae59 100644 --- a/src/main/java/ch/njol/skript/util/EmptyStacktraceException.java +++ b/src/main/java/ch/njol/skript/util/EmptyStacktraceException.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; /** diff --git a/src/main/java/ch/njol/skript/util/EnchantmentType.java b/src/main/java/ch/njol/skript/util/EnchantmentType.java index dd8ab383128..6301da13d9e 100644 --- a/src/main/java/ch/njol/skript/util/EnchantmentType.java +++ b/src/main/java/ch/njol/skript/util/EnchantmentType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.aliases.ItemType; diff --git a/src/main/java/ch/njol/skript/util/EnumUtils.java b/src/main/java/ch/njol/skript/util/EnumUtils.java index bc7fd40b512..ef537c7612b 100644 --- a/src/main/java/ch/njol/skript/util/EnumUtils.java +++ b/src/main/java/ch/njol/skript/util/EnumUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/util/ExceptionUtils.java b/src/main/java/ch/njol/skript/util/ExceptionUtils.java index 366a2363583..45693febda2 100644 --- a/src/main/java/ch/njol/skript/util/ExceptionUtils.java +++ b/src/main/java/ch/njol/skript/util/ExceptionUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.io.IOException; diff --git a/src/main/java/ch/njol/skript/util/Experience.java b/src/main/java/ch/njol/skript/util/Experience.java index 3953f31a973..6ee666cfefd 100644 --- a/src/main/java/ch/njol/skript/util/Experience.java +++ b/src/main/java/ch/njol/skript/util/Experience.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/util/FileUtils.java b/src/main/java/ch/njol/skript/util/FileUtils.java index 6ad8b964e25..a808611253d 100644 --- a/src/main/java/ch/njol/skript/util/FileUtils.java +++ b/src/main/java/ch/njol/skript/util/FileUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.io.File; diff --git a/src/main/java/ch/njol/skript/util/GameruleValue.java b/src/main/java/ch/njol/skript/util/GameruleValue.java index 1544a24e152..091b0e63e43 100644 --- a/src/main/java/ch/njol/skript/util/GameruleValue.java +++ b/src/main/java/ch/njol/skript/util/GameruleValue.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/util/LiteralUtils.java b/src/main/java/ch/njol/skript/util/LiteralUtils.java index e980b7bcb07..a94d719b897 100644 --- a/src/main/java/ch/njol/skript/util/LiteralUtils.java +++ b/src/main/java/ch/njol/skript/util/LiteralUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.stream.Stream; diff --git a/src/main/java/ch/njol/skript/util/PotionDataUtils.java b/src/main/java/ch/njol/skript/util/PotionDataUtils.java index 4bc7adbc153..37b12321a9f 100644 --- a/src/main/java/ch/njol/skript/util/PotionDataUtils.java +++ b/src/main/java/ch/njol/skript/util/PotionDataUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/util/PotionEffectUtils.java b/src/main/java/ch/njol/skript/util/PotionEffectUtils.java index b27c15b73a0..2516b045649 100644 --- a/src/main/java/ch/njol/skript/util/PotionEffectUtils.java +++ b/src/main/java/ch/njol/skript/util/PotionEffectUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/skript/util/SkriptColor.java b/src/main/java/ch/njol/skript/util/SkriptColor.java index 445c6bdac2d..ce9977d4c37 100644 --- a/src/main/java/ch/njol/skript/util/SkriptColor.java +++ b/src/main/java/ch/njol/skript/util/SkriptColor.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import ch.njol.skript.localization.Adjective; diff --git a/src/main/java/ch/njol/skript/util/Slot.java b/src/main/java/ch/njol/skript/util/Slot.java index ff1094bb303..3249972efa6 100644 --- a/src/main/java/ch/njol/skript/util/Slot.java +++ b/src/main/java/ch/njol/skript/util/Slot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; /** diff --git a/src/main/java/ch/njol/skript/util/StringMode.java b/src/main/java/ch/njol/skript/util/StringMode.java index 327fe5b98b3..bbd16546013 100644 --- a/src/main/java/ch/njol/skript/util/StringMode.java +++ b/src/main/java/ch/njol/skript/util/StringMode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; /** diff --git a/src/main/java/ch/njol/skript/util/StructureType.java b/src/main/java/ch/njol/skript/util/StructureType.java index cd86d074cdb..74df73a7bb2 100644 --- a/src/main/java/ch/njol/skript/util/StructureType.java +++ b/src/main/java/ch/njol/skript/util/StructureType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.HashMap; diff --git a/src/main/java/ch/njol/skript/util/Task.java b/src/main/java/ch/njol/skript/util/Task.java index 86d4c03cac5..e4cc9244875 100644 --- a/src/main/java/ch/njol/skript/util/Task.java +++ b/src/main/java/ch/njol/skript/util/Task.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.concurrent.Callable; diff --git a/src/main/java/ch/njol/skript/util/Time.java b/src/main/java/ch/njol/skript/util/Time.java index 30cf6c8b506..cba21da59af 100644 --- a/src/main/java/ch/njol/skript/util/Time.java +++ b/src/main/java/ch/njol/skript/util/Time.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.regex.Matcher; diff --git a/src/main/java/ch/njol/skript/util/Timeperiod.java b/src/main/java/ch/njol/skript/util/Timeperiod.java index 1144e0b5ab2..b700521f4fa 100644 --- a/src/main/java/ch/njol/skript/util/Timeperiod.java +++ b/src/main/java/ch/njol/skript/util/Timeperiod.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/util/Utils.java b/src/main/java/ch/njol/skript/util/Utils.java index 2cda7d3109b..d9704829b9b 100644 --- a/src/main/java/ch/njol/skript/util/Utils.java +++ b/src/main/java/ch/njol/skript/util/Utils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.io.File; @@ -58,6 +40,7 @@ import net.md_5.bungee.api.ChatColor; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; +import org.skriptlang.skript.util.ClassLoader; /** * Utility class. @@ -70,7 +53,7 @@ public abstract class Utils { protected final static Deque plurals = new LinkedList<>(); static { - plurals.add(new WordEnding("axe", "axes")); + plurals.add(new WordEnding("axe", "axes")); // not complete since we have battleaxe, etc. plurals.add(new WordEnding("x", "xes")); plurals.add(new WordEnding("ay", "ays")); @@ -79,14 +62,20 @@ public abstract class Utils { plurals.add(new WordEnding("oy", "oys")); plurals.add(new WordEnding("uy", "uys")); plurals.add(new WordEnding("kie", "kies")); - plurals.add(new WordEnding("zombie", "zombies")); + plurals.add(new WordEnding("zombie", "zombies", true)); plurals.add(new WordEnding("y", "ies")); - plurals.add(new WordEnding("wife", "wives")); // we have to do the -ife -> ives first + plurals.add(new WordEnding("wife", "wives", true)); // we have to do the -ife -> ives first plurals.add(new WordEnding("life", "lives")); - plurals.add(new WordEnding("knife", "knives")); + plurals.add(new WordEnding("knife", "knives", true)); plurals.add(new WordEnding("ive", "ives")); - plurals.add(new WordEnding("elf", "elves")); // self shelf elf + + plurals.add(new WordEnding("lf", "lves")); // self shelf elf wolf half etc. + plurals.add(new WordEnding("thief", "thieves", true)); + plurals.add(new WordEnding("ief", "iefs")); // chiefs, fiefs, briefs + + plurals.add(new WordEnding("hoof", "hooves")); + plurals.add(new WordEnding("fe", "ves"));// most -f words' plurals can end in -fs as well as -ves plurals.add(new WordEnding("h", "hes")); @@ -97,16 +86,18 @@ public abstract class Utils { plurals.add(new WordEnding("api", "apis")); // api fix plurals.add(new WordEnding("us", "i")); - plurals.add(new WordEnding("hoe", "hoes")); - plurals.add(new WordEnding("toe", "toes")); + plurals.add(new WordEnding("hoe", "hoes", true)); + plurals.add(new WordEnding("toe", "toes", true)); + plurals.add(new WordEnding("foe", "foes", true)); + plurals.add(new WordEnding("woe", "woes", true)); plurals.add(new WordEnding("o", "oes")); - plurals.add(new WordEnding("alias", "aliases")); - plurals.add(new WordEnding("gas", "gases")); + plurals.add(new WordEnding("alias", "aliases", true)); + plurals.add(new WordEnding("gas", "gases", true)); - plurals.add(new WordEnding("child", "children")); + plurals.add(new WordEnding("child", "children")); // grandchild, etc. - plurals.add(new WordEnding("sheep", "sheep")); + plurals.add(new WordEnding("sheep", "sheep", true)); // general ending plurals.add(new WordEnding("", "s")); @@ -122,7 +113,7 @@ public static String join(final Object[] objects) { b.append(", "); b.append(Classes.toString(objects[i])); } - return "" + b.toString(); + return b.toString(); } public static String join(final Iterable objects) { @@ -136,7 +127,7 @@ public static String join(final Iterable objects) { first = false; b.append(Classes.toString(o)); } - return "" + b.toString(); + return b.toString(); } @SuppressWarnings("unchecked") @@ -152,7 +143,7 @@ public static Pair getAmount(String s) { } else if (s.matches("an? .+")) { return new Pair<>(s.split(" ", 2)[1], 1); } - return new Pair<>(s, Integer.valueOf(-1)); + return new Pair<>(s, -1); } // public final static class AmountResponse { @@ -208,49 +199,25 @@ public static Pair getAmount(String s) { * as well. Use an empty array to load all subpackages of the base package. * @throws IOException If some error occurred attempting to read the plugin's jar file. * @return This SkriptAddon + * @deprecated Use {@link org.skriptlang.skript.util.ClassLoader}. */ + @Deprecated public static Class[] getClasses(Plugin plugin, String basePackage, String... subPackages) throws IOException { - assert subPackages != null; - JarFile jar = new JarFile(getFile(plugin)); - for (int i = 0; i < subPackages.length; i++) - subPackages[i] = subPackages[i].replace('.', '/') + "/"; - basePackage = basePackage.replace('.', '/') + "/"; List> classes = new ArrayList<>(); - try { - List classNames = new ArrayList<>(); - - for (JarEntry e : new EnumerationIterable<>(jar.entries())) { - if (e.getName().startsWith(basePackage) && e.getName().endsWith(".class") && !e.getName().endsWith("package-info.class")) { - boolean load = subPackages.length == 0; - for (String sub : subPackages) { - if (e.getName().startsWith(sub, basePackage.length())) { - load = true; - break; - } - } - - if (load) - classNames.add(e.getName().replace('/', '.').substring(0, e.getName().length() - ".class".length())); - } - } - - classNames.sort(String::compareToIgnoreCase); - - for (String c : classNames) { - try { - classes.add(Class.forName(c, true, plugin.getClass().getClassLoader())); - } catch (ClassNotFoundException | NoClassDefFoundError ex) { - Skript.exception(ex, "Cannot load class " + c); - } catch (ExceptionInInitializerError err) { - Skript.exception(err.getCause(), "class " + c + " generated an exception while loading"); - } - } - } finally { - try { - jar.close(); - } catch (IOException e) {} + ClassLoader loader = ClassLoader.builder() + .basePackage(basePackage) + .addSubPackages(subPackages) + .deep(true) + .initialize(true) + .forEachClass(classes::add) + .build(); + File jarFile = getFile(plugin); + if (jarFile != null) { + loader.loadClasses(plugin.getClass(), jarFile); + } else { + loader.loadClasses(plugin.getClass()); } - return classes.toArray(new Class[classes.size()]); + return classes.toArray(new Class[0]); } /** @@ -285,14 +252,55 @@ public static File getFile(Plugin plugin) { public static NonNullPair getEnglishPlural(String word) { assert word != null; if (word.isEmpty()) - return new NonNullPair<>("", Boolean.FALSE); + return new NonNullPair<>("", false); + if (!couldBeSingular(word)) { + for (final WordEnding ending : plurals) { + if (ending.isCompleteWord()) { + // Complete words shouldn't be used as partial pieces + if (word.length() != ending.plural().length()) + continue; + } + if (word.endsWith(ending.plural())) + return new NonNullPair<>( + word.substring(0, word.length() - ending.plural().length()) + ending.singular(), + true + ); + if (word.endsWith(ending.plural().toUpperCase(Locale.ENGLISH))) + return new NonNullPair<>( + word.substring(0, word.length() - ending.plural().length()) + + ending.singular().toUpperCase(Locale.ENGLISH), + true + ); + } + } + return new NonNullPair<>(word, false); + } + + private static boolean couldBeSingular(String word) { for (final WordEnding ending : plurals) { - if (word.endsWith(ending.plural())) - return new NonNullPair<>(word.substring(0, word.length() - ending.plural().length()) + ending.singular(), Boolean.TRUE); - if (word.endsWith(ending.plural().toUpperCase(Locale.ENGLISH))) - return new NonNullPair<>(word.substring(0, word.length() - ending.plural().length()) + ending.singular().toUpperCase(Locale.ENGLISH), Boolean.TRUE); + if (ending.singular().isBlank()) + continue; + if (ending.isCompleteWord() && ending.singular().length() != word.length()) + continue; // Skip complete words + + if (word.endsWith(ending.singular()) || word.toLowerCase().endsWith(ending.singular())) { + return true; + } } - return new NonNullPair<>(word, Boolean.FALSE); + return false; + } + + /** + * Adds a singular/plural word override for the given words. + * This is inserted first in the list of words to be checked: it will always be matched + * and will override all other plurality rules. + * This will only match the word exactly, and will not apply to derivations of the word. + * + * @param singular The singular form of the word + * @param plural The plural form of the word + */ + public static void addPluralOverride(String singular, String plural) { + Utils.plurals.addFirst(new WordEnding(singular, plural, true)); } /** @@ -304,6 +312,11 @@ public static NonNullPair getEnglishPlural(String word) { public static String toEnglishPlural(String word) { assert word != null && word.length() != 0; for (WordEnding ending : plurals) { + if (ending.isCompleteWord()) { + // Complete words shouldn't be used as partial pieces + if (word.length() != ending.singular().length()) + continue; + } if (word.endsWith(ending.singular())) return word.substring(0, word.length() - ending.singular().length()) + ending.plural(); } @@ -536,9 +549,6 @@ public static CompletableFuture sendPluginMessage(Player pla final static Map chat = new HashMap<>(); final static Map englishChat = new HashMap<>(); - public final static boolean HEX_SUPPORTED = Skript.isRunningMinecraft(1, 16); - public final static boolean COPY_SUPPORTED = Skript.isRunningMinecraft(1, 15); - static { Language.addListener(new LanguageChangeListener() { @Override @@ -565,43 +575,17 @@ public static String getChatStyle(final String s) { return chat.get(s); } - private final static Pattern stylePattern = Pattern.compile("<([^<>]+)>"); - /** * Replaces <chat styles> in the message * * @param message * @return message with localised chat styles converted to Minecraft's format */ - public static String replaceChatStyles(final String message) { + public static @NotNull String replaceChatStyles(String message) { if (message.isEmpty()) return message; - String m = StringUtils.replaceAll(Matcher.quoteReplacement("" + message.replace("<>", "")), stylePattern, new Callback() { - @Override - public String run(final Matcher m) { - SkriptColor color = SkriptColor.fromName("" + m.group(1)); - if (color != null) - return color.getFormattedChat(); - final String tag = m.group(1).toLowerCase(Locale.ENGLISH); - final String f = chat.get(tag); - if (f != null) - return f; - if (HEX_SUPPORTED && tag.startsWith("#")) { // Check for parsing hex colors - ChatColor chatColor = parseHexColor(tag); - if (chatColor != null) - return chatColor.toString(); - } - return "" + m.group(); - } - }); - assert m != null; - // Restore user input post-sanitization - // Sometimes, the message has already been restored - if (!message.equals(m)) { - m = m.replace("\\$", "$").replace("\\\\", "\\"); - } - m = ChatColor.translateAlternateColorCodes('&', "" + m); - return "" + m; + + return replaceChatStyle(message.replace("<>", "")); } /** @@ -611,54 +595,81 @@ public String run(final Matcher m) { * @param message * @return message with english chat styles converted to Minecraft's format */ - public static String replaceEnglishChatStyles(final String message) { + public static @NotNull String replaceEnglishChatStyles(String message) { if (message.isEmpty()) return message; - String m = StringUtils.replaceAll(Matcher.quoteReplacement(message), stylePattern, new Callback() { - @Override - public String run(final Matcher m) { - SkriptColor color = SkriptColor.fromName("" + m.group(1)); - if (color != null) - return color.getFormattedChat(); - final String tag = m.group(1).toLowerCase(Locale.ENGLISH); - final String f = englishChat.get(tag); - if (f != null) - return f; - if (HEX_SUPPORTED && tag.startsWith("#")) { // Check for parsing hex colors - ChatColor chatColor = parseHexColor(tag); - if (chatColor != null) - return chatColor.toString(); - } - return "" + m.group(); + + return replaceChatStyle(message); + } + + private final static Pattern STYLE_PATTERN = Pattern.compile("<([^<>]+)>"); + + private static @NotNull String replaceChatStyle(String message) { + String m = StringUtils.replaceAll(Matcher.quoteReplacement(message), STYLE_PATTERN, matcher -> { + SkriptColor color = SkriptColor.fromName(matcher.group(1)); + if (color != null) + return color.getFormattedChat(); + + String tag = matcher.group(1).toLowerCase(Locale.ENGLISH); + String f = englishChat.get(tag); + if (f != null) + return f; + + if (tag.startsWith("#")) { + ChatColor chatColor = parseHexColor(tag); + if (chatColor != null) + return chatColor.toString(); + } else if (tag.startsWith("u:") || tag.startsWith("unicode:")) { + String character = parseUnicode(tag); + if (character != null) + return character; } + return matcher.group(); }); - assert m != null; + // Restore user input post-sanitization // Sometimes, the message has already been restored if (!message.equals(m)) { m = m.replace("\\$", "$").replace("\\\\", "\\"); } - m = ChatColor.translateAlternateColorCodes('&', "" + m); - return "" + m; + + return ChatColor.translateAlternateColorCodes('&', m); } - private static final Pattern HEX_PATTERN = Pattern.compile("(?i)#{0,2}[0-9a-f]{6}"); + private static final Pattern UNICODE_PATTERN = Pattern.compile("(?i)u(?:nicode)?:(?[0-9a-f]{4,})"); + + /** + * Tries to extract a Unicode character from the given string. + * @param string The string. + * @return The Unicode character, or null if it could not be parsed. + */ + public static @Nullable String parseUnicode(String string) { + Matcher matcher = UNICODE_PATTERN.matcher(string); + if (!matcher.matches()) + return null; + + try { + return Character.toString(Integer.parseInt(matcher.group("code"), 16)); + } catch (IllegalArgumentException ex) { + return null; + } + } + + private static final Pattern HEX_PATTERN = Pattern.compile("(?i)#{0,2}(?[0-9a-f]{6})"); /** * Tries to get a {@link ChatColor} from the given string. - * @param hex The hex code to parse. + * @param string The string code to parse. * @return The ChatColor, or null if it couldn't be parsed. */ - @SuppressWarnings("null") - @Nullable - public static ChatColor parseHexColor(String hex) { - if (!HEX_SUPPORTED || !HEX_PATTERN.matcher(hex).matches()) // Proper hex code validation + public static @Nullable ChatColor parseHexColor(String string) { + Matcher matcher = HEX_PATTERN.matcher(string); + if (!matcher.matches()) return null; - hex = hex.replace("#", ""); try { - return ChatColor.of('#' + hex.substring(0, 6)); - } catch (IllegalArgumentException e) { + return ChatColor.of('#' + matcher.group("code")); + } catch (IllegalArgumentException ex) { return null; } } @@ -809,13 +820,10 @@ public static boolean isInteger(Number... numbers) { return true; } - protected static class WordEnding { // To be a record in 2.10 - - private final String singular, plural; + protected record WordEnding(String singular, String plural, boolean isCompleteWord) { - private WordEnding(String singular, String plural) { - this.singular = singular; - this.plural = plural; + public WordEnding(String singular, String plural) { + this(singular, plural, false); } public String singular() { @@ -829,8 +837,7 @@ public String plural() { @Override public boolean equals(Object object) { if (this == object) return true; - if (!(object instanceof WordEnding)) return false; - WordEnding ending = (WordEnding) object; + if (!(object instanceof WordEnding ending)) return false; return Objects.equals(singular, ending.singular) && Objects.equals(plural, ending.plural); } diff --git a/src/main/java/ch/njol/skript/util/Version.java b/src/main/java/ch/njol/skript/util/Version.java index bfe994175df..4a2141c2427 100644 --- a/src/main/java/ch/njol/skript/util/Version.java +++ b/src/main/java/ch/njol/skript/util/Version.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.io.Serializable; diff --git a/src/main/java/ch/njol/skript/util/WeatherType.java b/src/main/java/ch/njol/skript/util/WeatherType.java index 2ace679dc43..b9f8363a16b 100644 --- a/src/main/java/ch/njol/skript/util/WeatherType.java +++ b/src/main/java/ch/njol/skript/util/WeatherType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util; import java.util.HashMap; diff --git a/src/main/java/ch/njol/skript/util/chat/BungeeConverter.java b/src/main/java/ch/njol/skript/util/chat/BungeeConverter.java index 3ceb4bf29ed..4189cb1298b 100644 --- a/src/main/java/ch/njol/skript/util/chat/BungeeConverter.java +++ b/src/main/java/ch/njol/skript/util/chat/BungeeConverter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.chat; import java.util.Arrays; diff --git a/src/main/java/ch/njol/skript/util/chat/ChatCode.java b/src/main/java/ch/njol/skript/util/chat/ChatCode.java index b7ea7995f6d..af61f884633 100644 --- a/src/main/java/ch/njol/skript/util/chat/ChatCode.java +++ b/src/main/java/ch/njol/skript/util/chat/ChatCode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.chat; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/util/chat/ChatMessages.java b/src/main/java/ch/njol/skript/util/chat/ChatMessages.java index b032b76207e..b8bcd5d4ed9 100644 --- a/src/main/java/ch/njol/skript/util/chat/ChatMessages.java +++ b/src/main/java/ch/njol/skript/util/chat/ChatMessages.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.chat; import ch.njol.skript.Skript; @@ -95,8 +77,6 @@ public void onLanguageChange() { Skript.debug("Parsing message style lang files"); for (SkriptChatCode code : SkriptChatCode.values()) { assert code != null; - if (code == SkriptChatCode.copy_to_clipboard && !Utils.COPY_SUPPORTED) - continue; registerChatCode(code); } @@ -231,7 +211,7 @@ else if (c2 == '>') } name = name.toLowerCase(Locale.ENGLISH); // Tags are case-insensitive - boolean tryHex = Utils.HEX_SUPPORTED && name.startsWith("#"); + boolean tryHex = name.startsWith("#"); ChatColor chatColor = null; if (tryHex) { chatColor = Utils.parseHexColor(name); @@ -279,7 +259,7 @@ else if (c2 == '>') char color = chars[i + 1]; - boolean tryHex = Utils.HEX_SUPPORTED && color == 'x'; + boolean tryHex = color == 'x'; ChatColor chatColor = null; if (tryHex && i + 14 < chars.length) { // Try to parse hex "&x&1&2&3&4&5&6" chatColor = Utils.parseHexColor(msg.substring(i + 2, i + 14).replace("&", "").replace("§", "")); @@ -442,7 +422,7 @@ public static List fromParsedString(String msg) { char color = chars[i + 1]; - boolean tryHex = Utils.HEX_SUPPORTED && color == 'x'; + boolean tryHex = color == 'x'; ChatColor chatColor = null; if (tryHex && i + 14 < chars.length) { // Try to parse hex "&x&1&2&3&4&5&6" chatColor = Utils.parseHexColor(msg.substring(i + 2, i + 14).replace("&", "").replace("§", "")); @@ -600,9 +580,8 @@ public static String stripStyles(String text) { builder.append(component.text); } String plain = builder.toString(); - - if (Utils.HEX_SUPPORTED) // Strip '§x', '&x' - plain = HEX_COLOR_PATTERN.matcher(plain).replaceAll(""); + + plain = HEX_COLOR_PATTERN.matcher(plain).replaceAll(""); result = ANY_COLOR_PATTERN.matcher(plain).replaceAll(""); // strips colors & or § (ex. &5) } while (!previous.equals(result)); diff --git a/src/main/java/ch/njol/skript/util/chat/LinkParseMode.java b/src/main/java/ch/njol/skript/util/chat/LinkParseMode.java index 227008969ed..7e11aabf30e 100644 --- a/src/main/java/ch/njol/skript/util/chat/LinkParseMode.java +++ b/src/main/java/ch/njol/skript/util/chat/LinkParseMode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.chat; /** diff --git a/src/main/java/ch/njol/skript/util/chat/MessageComponent.java b/src/main/java/ch/njol/skript/util/chat/MessageComponent.java index 036b5ad8724..b03dad3f7b1 100644 --- a/src/main/java/ch/njol/skript/util/chat/MessageComponent.java +++ b/src/main/java/ch/njol/skript/util/chat/MessageComponent.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.chat; import java.lang.reflect.Type; diff --git a/src/main/java/ch/njol/skript/util/chat/SkriptChatCode.java b/src/main/java/ch/njol/skript/util/chat/SkriptChatCode.java index ba675614a53..201b3e1c793 100644 --- a/src/main/java/ch/njol/skript/util/chat/SkriptChatCode.java +++ b/src/main/java/ch/njol/skript/util/chat/SkriptChatCode.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.chat; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/util/slot/CursorSlot.java b/src/main/java/ch/njol/skript/util/slot/CursorSlot.java index 3dda986c103..c0e9b08363a 100644 --- a/src/main/java/ch/njol/skript/util/slot/CursorSlot.java +++ b/src/main/java/ch/njol/skript/util/slot/CursorSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; import org.bukkit.entity.Player; diff --git a/src/main/java/ch/njol/skript/util/slot/DroppedItemSlot.java b/src/main/java/ch/njol/skript/util/slot/DroppedItemSlot.java index 859ad635365..3af5bb9eb65 100644 --- a/src/main/java/ch/njol/skript/util/slot/DroppedItemSlot.java +++ b/src/main/java/ch/njol/skript/util/slot/DroppedItemSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; import org.bukkit.entity.Item; diff --git a/src/main/java/ch/njol/skript/util/slot/EquipmentSlot.java b/src/main/java/ch/njol/skript/util/slot/EquipmentSlot.java index 9d86efb1c2e..a5d6ee21e0e 100644 --- a/src/main/java/ch/njol/skript/util/slot/EquipmentSlot.java +++ b/src/main/java/ch/njol/skript/util/slot/EquipmentSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; import java.util.Locale; diff --git a/src/main/java/ch/njol/skript/util/slot/InventorySlot.java b/src/main/java/ch/njol/skript/util/slot/InventorySlot.java index 3d3feafbbd7..7ace6271dbc 100644 --- a/src/main/java/ch/njol/skript/util/slot/InventorySlot.java +++ b/src/main/java/ch/njol/skript/util/slot/InventorySlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/util/slot/ItemFrameSlot.java b/src/main/java/ch/njol/skript/util/slot/ItemFrameSlot.java index 2f68a96dc0e..a5140d1dad4 100644 --- a/src/main/java/ch/njol/skript/util/slot/ItemFrameSlot.java +++ b/src/main/java/ch/njol/skript/util/slot/ItemFrameSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; import org.bukkit.entity.ItemFrame; diff --git a/src/main/java/ch/njol/skript/util/slot/Slot.java b/src/main/java/ch/njol/skript/util/slot/Slot.java index a9b9abf3867..515cdabfa46 100644 --- a/src/main/java/ch/njol/skript/util/slot/Slot.java +++ b/src/main/java/ch/njol/skript/util/slot/Slot.java @@ -1,50 +1,41 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; +import ch.njol.skript.aliases.Aliases; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.bukkitutil.ItemUtils; +import ch.njol.skript.lang.util.common.AnyAmount; +import ch.njol.skript.lang.util.common.AnyNamed; +import org.bukkit.Bukkit; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.Nullable; import ch.njol.skript.lang.Debuggable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.UnknownNullability; /** * Represents a container for a single item. It could be an ordinary inventory * slot or perhaps an item frame. */ -public abstract class Slot implements Debuggable { - +public abstract class Slot implements Debuggable, AnyNamed, AnyAmount { + protected Slot() {} - + @Nullable public abstract ItemStack getItem(); - + public abstract void setItem(final @Nullable ItemStack item); - + public abstract int getAmount(); - + public abstract void setAmount(int amount); - + @Override public final String toString() { return toString(null, false); } - + /** * Checks if given slot is in same position with this. * Ignores slot contents. @@ -52,4 +43,52 @@ public final String toString() { * @return True if positions equal, false otherwise. */ public abstract boolean isSameSlot(Slot o); + + /** + * @return The name of the item in this slot + */ + @Override + public @UnknownNullability String name() { + ItemStack stack = this.getItem(); + if (stack != null && stack.hasItemMeta()) { + ItemMeta meta = stack.getItemMeta(); + return meta.hasDisplayName() ? meta.getDisplayName() : null; + } + return null; + } + + @Override + public boolean supportsNameChange() { + return true; + } + + /** + * @param name The name to change + */ + @Override + public void setName(String name) { + ItemStack stack = this.getItem(); + if (stack != null && !ItemUtils.isAir(stack.getType())) { + ItemMeta meta = stack.hasItemMeta() ? stack.getItemMeta() : Bukkit.getItemFactory().getItemMeta(stack.getType()); + meta.setDisplayName(name); + stack.setItemMeta(meta); + this.setItem(stack); + } + } + + @Override + public @NotNull Number amount() { + return this.getAmount(); + } + + @Override + public boolean supportsAmountChange() { + return true; + } + + @Override + public void setAmount(@Nullable Number amount) { + this.setAmount(amount != null ? amount.intValue() : 0); + } + } diff --git a/src/main/java/ch/njol/skript/util/slot/SlotWithIndex.java b/src/main/java/ch/njol/skript/util/slot/SlotWithIndex.java index 17efbfe400a..1fff41f286e 100644 --- a/src/main/java/ch/njol/skript/util/slot/SlotWithIndex.java +++ b/src/main/java/ch/njol/skript/util/slot/SlotWithIndex.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; /** diff --git a/src/main/java/ch/njol/skript/util/slot/ThrowableProjectileSlot.java b/src/main/java/ch/njol/skript/util/slot/ThrowableProjectileSlot.java index 80ffa552dcc..e1d4444213a 100644 --- a/src/main/java/ch/njol/skript/util/slot/ThrowableProjectileSlot.java +++ b/src/main/java/ch/njol/skript/util/slot/ThrowableProjectileSlot.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.slot; import org.bukkit.Material; diff --git a/src/main/java/ch/njol/skript/util/visual/ParticleOption.java b/src/main/java/ch/njol/skript/util/visual/ParticleOption.java index 690b89e9a84..0fae7e7b214 100644 --- a/src/main/java/ch/njol/skript/util/visual/ParticleOption.java +++ b/src/main/java/ch/njol/skript/util/visual/ParticleOption.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.visual; import ch.njol.skript.util.Color; diff --git a/src/main/java/ch/njol/skript/util/visual/VisualEffect.java b/src/main/java/ch/njol/skript/util/visual/VisualEffect.java index 02aa5a25a6c..99619eb447e 100644 --- a/src/main/java/ch/njol/skript/util/visual/VisualEffect.java +++ b/src/main/java/ch/njol/skript/util/visual/VisualEffect.java @@ -1,22 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.visual; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/util/visual/VisualEffectType.java b/src/main/java/ch/njol/skript/util/visual/VisualEffectType.java index b9220074293..fa8dd41d9ce 100644 --- a/src/main/java/ch/njol/skript/util/visual/VisualEffectType.java +++ b/src/main/java/ch/njol/skript/util/visual/VisualEffectType.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.visual; import ch.njol.skript.localization.Language; diff --git a/src/main/java/ch/njol/skript/util/visual/VisualEffects.java b/src/main/java/ch/njol/skript/util/visual/VisualEffects.java index 0d37ad1e7dc..f43d7f10928 100644 --- a/src/main/java/ch/njol/skript/util/visual/VisualEffects.java +++ b/src/main/java/ch/njol/skript/util/visual/VisualEffects.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.util.visual; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/variables/FlatFileStorage.java b/src/main/java/ch/njol/skript/variables/FlatFileStorage.java index e18ef041d71..7c7eaa5e71e 100644 --- a/src/main/java/ch/njol/skript/variables/FlatFileStorage.java +++ b/src/main/java/ch/njol/skript/variables/FlatFileStorage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/variables/MySQLStorage.java b/src/main/java/ch/njol/skript/variables/MySQLStorage.java index 884529388ab..ff5ac5d39ac 100644 --- a/src/main/java/ch/njol/skript/variables/MySQLStorage.java +++ b/src/main/java/ch/njol/skript/variables/MySQLStorage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import ch.njol.skript.config.SectionNode; diff --git a/src/main/java/ch/njol/skript/variables/SQLStorage.java b/src/main/java/ch/njol/skript/variables/SQLStorage.java index a5d2b4c4444..08b83f8d0d2 100644 --- a/src/main/java/ch/njol/skript/variables/SQLStorage.java +++ b/src/main/java/ch/njol/skript/variables/SQLStorage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import java.io.File; diff --git a/src/main/java/ch/njol/skript/variables/SQLiteStorage.java b/src/main/java/ch/njol/skript/variables/SQLiteStorage.java index bb52883eba0..57032218f95 100644 --- a/src/main/java/ch/njol/skript/variables/SQLiteStorage.java +++ b/src/main/java/ch/njol/skript/variables/SQLiteStorage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import java.io.File; diff --git a/src/main/java/ch/njol/skript/variables/SerializedVariable.java b/src/main/java/ch/njol/skript/variables/SerializedVariable.java index b66b9acc333..258a251a9b5 100644 --- a/src/main/java/ch/njol/skript/variables/SerializedVariable.java +++ b/src/main/java/ch/njol/skript/variables/SerializedVariable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/skript/variables/TypeHints.java b/src/main/java/ch/njol/skript/variables/TypeHints.java index 7340d2fd970..12b7768f365 100644 --- a/src/main/java/ch/njol/skript/variables/TypeHints.java +++ b/src/main/java/ch/njol/skript/variables/TypeHints.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import java.util.ArrayDeque; diff --git a/src/main/java/ch/njol/skript/variables/Variables.java b/src/main/java/ch/njol/skript/variables/Variables.java index 8362128a7d1..090f060bdd4 100644 --- a/src/main/java/ch/njol/skript/variables/Variables.java +++ b/src/main/java/ch/njol/skript/variables/Variables.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/skript/variables/VariablesMap.java b/src/main/java/ch/njol/skript/variables/VariablesMap.java index cef587e9f38..9934f46eba5 100644 --- a/src/main/java/ch/njol/skript/variables/VariablesMap.java +++ b/src/main/java/ch/njol/skript/variables/VariablesMap.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import ch.njol.skript.lang.Variable; diff --git a/src/main/java/ch/njol/skript/variables/VariablesStorage.java b/src/main/java/ch/njol/skript/variables/VariablesStorage.java index 77e7934f591..27e5560ecb4 100644 --- a/src/main/java/ch/njol/skript/variables/VariablesStorage.java +++ b/src/main/java/ch/njol/skript/variables/VariablesStorage.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import java.io.File; diff --git a/src/main/java/ch/njol/util/Callback.java b/src/main/java/ch/njol/util/Callback.java index efce012642b..ac0ddadbdc8 100644 --- a/src/main/java/ch/njol/util/Callback.java +++ b/src/main/java/ch/njol/util/Callback.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/util/CaseInsensitiveString.java b/src/main/java/ch/njol/util/CaseInsensitiveString.java index 1f77cd834a9..257fb791f47 100644 --- a/src/main/java/ch/njol/util/CaseInsensitiveString.java +++ b/src/main/java/ch/njol/util/CaseInsensitiveString.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import java.io.Serializable; diff --git a/src/main/java/ch/njol/util/Checker.java b/src/main/java/ch/njol/util/Checker.java index 95b8f02c073..0b7f5bb0098 100644 --- a/src/main/java/ch/njol/util/Checker.java +++ b/src/main/java/ch/njol/util/Checker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; @FunctionalInterface diff --git a/src/main/java/ch/njol/util/Closeable.java b/src/main/java/ch/njol/util/Closeable.java index ddeb460d301..11c7c358c09 100644 --- a/src/main/java/ch/njol/util/Closeable.java +++ b/src/main/java/ch/njol/util/Closeable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; /** diff --git a/src/main/java/ch/njol/util/EnumTypeAdapter.java b/src/main/java/ch/njol/util/EnumTypeAdapter.java index 4a955bb6dfb..8031e753fce 100644 --- a/src/main/java/ch/njol/util/EnumTypeAdapter.java +++ b/src/main/java/ch/njol/util/EnumTypeAdapter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import com.google.gson.Gson; diff --git a/src/main/java/ch/njol/util/Kleenean.java b/src/main/java/ch/njol/util/Kleenean.java index 6939a301e1c..09e6dabf07e 100644 --- a/src/main/java/ch/njol/util/Kleenean.java +++ b/src/main/java/ch/njol/util/Kleenean.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import java.util.Locale; diff --git a/src/main/java/ch/njol/util/LoggerFilter.java b/src/main/java/ch/njol/util/LoggerFilter.java index b2e1aa6db8c..6f15d88af34 100644 --- a/src/main/java/ch/njol/util/LoggerFilter.java +++ b/src/main/java/ch/njol/util/LoggerFilter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import java.util.ArrayList; diff --git a/src/main/java/ch/njol/util/Math2.java b/src/main/java/ch/njol/util/Math2.java index d17ac6910d1..04e222f7698 100644 --- a/src/main/java/ch/njol/util/Math2.java +++ b/src/main/java/ch/njol/util/Math2.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import ch.njol.skript.Skript; diff --git a/src/main/java/ch/njol/util/NonNullPair.java b/src/main/java/ch/njol/util/NonNullPair.java index a02d8b0288c..39fba1de6b1 100644 --- a/src/main/java/ch/njol/util/NonNullPair.java +++ b/src/main/java/ch/njol/util/NonNullPair.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; /** diff --git a/src/main/java/ch/njol/util/NotifyingReference.java b/src/main/java/ch/njol/util/NotifyingReference.java index 8c173323f62..127a72d39c2 100644 --- a/src/main/java/ch/njol/util/NotifyingReference.java +++ b/src/main/java/ch/njol/util/NotifyingReference.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/util/NullableChecker.java b/src/main/java/ch/njol/util/NullableChecker.java index a8f5d53f8c6..c260d14f41d 100644 --- a/src/main/java/ch/njol/util/NullableChecker.java +++ b/src/main/java/ch/njol/util/NullableChecker.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/util/OpenCloseable.java b/src/main/java/ch/njol/util/OpenCloseable.java index 54d7bf547c1..6ba85bd42a6 100644 --- a/src/main/java/ch/njol/util/OpenCloseable.java +++ b/src/main/java/ch/njol/util/OpenCloseable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import java.util.ArrayDeque; diff --git a/src/main/java/ch/njol/util/Pair.java b/src/main/java/ch/njol/util/Pair.java index c17887f9778..a103491e0e6 100644 --- a/src/main/java/ch/njol/util/Pair.java +++ b/src/main/java/ch/njol/util/Pair.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import java.io.Serializable; diff --git a/src/main/java/ch/njol/util/Predicate.java b/src/main/java/ch/njol/util/Predicate.java index f16b12968d2..be2607af2f4 100644 --- a/src/main/java/ch/njol/util/Predicate.java +++ b/src/main/java/ch/njol/util/Predicate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import javax.annotation.Nullable; diff --git a/src/main/java/ch/njol/util/Setter.java b/src/main/java/ch/njol/util/Setter.java index 6d03d4d6d14..6edc10a723a 100644 --- a/src/main/java/ch/njol/util/Setter.java +++ b/src/main/java/ch/njol/util/Setter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; /** diff --git a/src/main/java/ch/njol/util/SynchronizedReference.java b/src/main/java/ch/njol/util/SynchronizedReference.java index dfd7fbb9f5e..6786a0dac45 100644 --- a/src/main/java/ch/njol/util/SynchronizedReference.java +++ b/src/main/java/ch/njol/util/SynchronizedReference.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/util/Validate.java b/src/main/java/ch/njol/util/Validate.java index e47c320fb06..0f73e980f60 100644 --- a/src/main/java/ch/njol/util/Validate.java +++ b/src/main/java/ch/njol/util/Validate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import java.util.Collection; diff --git a/src/main/java/ch/njol/util/VectorMath.java b/src/main/java/ch/njol/util/VectorMath.java index 5db05ecc41b..553d7334d2a 100644 --- a/src/main/java/ch/njol/util/VectorMath.java +++ b/src/main/java/ch/njol/util/VectorMath.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util; import org.bukkit.util.Vector; diff --git a/src/main/java/ch/njol/util/coll/BidiHashMap.java b/src/main/java/ch/njol/util/coll/BidiHashMap.java index 47003277110..78c16cd0e87 100644 --- a/src/main/java/ch/njol/util/coll/BidiHashMap.java +++ b/src/main/java/ch/njol/util/coll/BidiHashMap.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll; import java.util.Collections; diff --git a/src/main/java/ch/njol/util/coll/BidiMap.java b/src/main/java/ch/njol/util/coll/BidiMap.java index b4afe6632d4..129fa9b23da 100644 --- a/src/main/java/ch/njol/util/coll/BidiMap.java +++ b/src/main/java/ch/njol/util/coll/BidiMap.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll; import java.util.Map; diff --git a/src/main/java/ch/njol/util/coll/CollectionUtils.java b/src/main/java/ch/njol/util/coll/CollectionUtils.java index ecda9c0294f..4440bebd020 100644 --- a/src/main/java/ch/njol/util/coll/CollectionUtils.java +++ b/src/main/java/ch/njol/util/coll/CollectionUtils.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll; import ch.njol.util.Pair; diff --git a/src/main/java/ch/njol/util/coll/CyclicList.java b/src/main/java/ch/njol/util/coll/CyclicList.java index a57bffed71e..556db77c53a 100644 --- a/src/main/java/ch/njol/util/coll/CyclicList.java +++ b/src/main/java/ch/njol/util/coll/CyclicList.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll; import java.lang.reflect.Array; diff --git a/src/main/java/ch/njol/util/coll/ReversedListView.java b/src/main/java/ch/njol/util/coll/ReversedListView.java index 632dc55924e..89fb5943fde 100644 --- a/src/main/java/ch/njol/util/coll/ReversedListView.java +++ b/src/main/java/ch/njol/util/coll/ReversedListView.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll; import java.lang.reflect.Array; diff --git a/src/main/java/ch/njol/util/coll/iterator/ArrayIterator.java b/src/main/java/ch/njol/util/coll/iterator/ArrayIterator.java index af8f3e3c062..d04ca2a6033 100644 --- a/src/main/java/ch/njol/util/coll/iterator/ArrayIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/ArrayIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import com.google.common.collect.PeekingIterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/CheckedIterator.java b/src/main/java/ch/njol/util/coll/iterator/CheckedIterator.java index f17ac3ae36c..fc2d1c3ef71 100644 --- a/src/main/java/ch/njol/util/coll/iterator/CheckedIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/CheckedIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/CombinedIterator.java b/src/main/java/ch/njol/util/coll/iterator/CombinedIterator.java index aee12ce0f97..b58e564c501 100644 --- a/src/main/java/ch/njol/util/coll/iterator/CombinedIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/CombinedIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/ConsumingIterator.java b/src/main/java/ch/njol/util/coll/iterator/ConsumingIterator.java index 5ad15280ade..e221a614602 100644 --- a/src/main/java/ch/njol/util/coll/iterator/ConsumingIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/ConsumingIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/EmptyIterable.java b/src/main/java/ch/njol/util/coll/iterator/EmptyIterable.java index 0b400a13414..05f0a016ad0 100644 --- a/src/main/java/ch/njol/util/coll/iterator/EmptyIterable.java +++ b/src/main/java/ch/njol/util/coll/iterator/EmptyIterable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/EmptyIterator.java b/src/main/java/ch/njol/util/coll/iterator/EmptyIterator.java index a8ac451cb12..4a75b57d008 100644 --- a/src/main/java/ch/njol/util/coll/iterator/EmptyIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/EmptyIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/EnumerationIterable.java b/src/main/java/ch/njol/util/coll/iterator/EnumerationIterable.java index 16b7d077434..9ffd90b7fe2 100644 --- a/src/main/java/ch/njol/util/coll/iterator/EnumerationIterable.java +++ b/src/main/java/ch/njol/util/coll/iterator/EnumerationIterable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Enumeration; diff --git a/src/main/java/ch/njol/util/coll/iterator/ImprovedIterator.java b/src/main/java/ch/njol/util/coll/iterator/ImprovedIterator.java index 3d9a4540447..9fe640faffd 100644 --- a/src/main/java/ch/njol/util/coll/iterator/ImprovedIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/ImprovedIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/IteratorIterable.java b/src/main/java/ch/njol/util/coll/iterator/IteratorIterable.java index cbec8b3907b..ab349f8bb92 100644 --- a/src/main/java/ch/njol/util/coll/iterator/IteratorIterable.java +++ b/src/main/java/ch/njol/util/coll/iterator/IteratorIterable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/ListRangeIterator.java b/src/main/java/ch/njol/util/coll/iterator/ListRangeIterator.java index e7626d62761..8f554d2dfc7 100644 --- a/src/main/java/ch/njol/util/coll/iterator/ListRangeIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/ListRangeIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/NonNullIterator.java b/src/main/java/ch/njol/util/coll/iterator/NonNullIterator.java index b60e8c3c19f..eca9cb4105a 100644 --- a/src/main/java/ch/njol/util/coll/iterator/NonNullIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/NonNullIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/ReversedListIterator.java b/src/main/java/ch/njol/util/coll/iterator/ReversedListIterator.java index 1db1efa24b4..4327bd9ee26 100644 --- a/src/main/java/ch/njol/util/coll/iterator/ReversedListIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/ReversedListIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.List; diff --git a/src/main/java/ch/njol/util/coll/iterator/SingleItemIterable.java b/src/main/java/ch/njol/util/coll/iterator/SingleItemIterable.java index d5246e1f131..2103374155d 100644 --- a/src/main/java/ch/njol/util/coll/iterator/SingleItemIterable.java +++ b/src/main/java/ch/njol/util/coll/iterator/SingleItemIterable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/SingleItemIterator.java b/src/main/java/ch/njol/util/coll/iterator/SingleItemIterator.java index 6038ed62312..805853ef6da 100644 --- a/src/main/java/ch/njol/util/coll/iterator/SingleItemIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/SingleItemIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/util/coll/iterator/StoppableIterator.java b/src/main/java/ch/njol/util/coll/iterator/StoppableIterator.java index 5db87f67bad..cf0688572d6 100644 --- a/src/main/java/ch/njol/util/coll/iterator/StoppableIterator.java +++ b/src/main/java/ch/njol/util/coll/iterator/StoppableIterator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.util.coll.iterator; import java.util.Iterator; diff --git a/src/main/java/ch/njol/yggdrasil/ClassResolver.java b/src/main/java/ch/njol/yggdrasil/ClassResolver.java index ec4ecfe8621..bb6c4328800 100644 --- a/src/main/java/ch/njol/yggdrasil/ClassResolver.java +++ b/src/main/java/ch/njol/yggdrasil/ClassResolver.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilInputStream.java b/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilInputStream.java index 87142f293a1..6926cb3ce8e 100644 --- a/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilInputStream.java +++ b/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilInputStream.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import ch.njol.util.coll.CollectionUtils; diff --git a/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilOutputStream.java b/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilOutputStream.java index f77b8c2405c..557762433a9 100644 --- a/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilOutputStream.java +++ b/src/main/java/ch/njol/yggdrasil/DefaultYggdrasilOutputStream.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import java.io.IOException; diff --git a/src/main/java/ch/njol/yggdrasil/FieldHandler.java b/src/main/java/ch/njol/yggdrasil/FieldHandler.java index ea894c68088..9cd34b5f2f7 100644 --- a/src/main/java/ch/njol/yggdrasil/FieldHandler.java +++ b/src/main/java/ch/njol/yggdrasil/FieldHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import ch.njol.yggdrasil.Fields.FieldContext; diff --git a/src/main/java/ch/njol/yggdrasil/Fields.java b/src/main/java/ch/njol/yggdrasil/Fields.java index 10f2c8f1c83..be64fccd971 100644 --- a/src/main/java/ch/njol/yggdrasil/Fields.java +++ b/src/main/java/ch/njol/yggdrasil/Fields.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import ch.njol.yggdrasil.Fields.FieldContext; diff --git a/src/main/java/ch/njol/yggdrasil/JRESerializer.java b/src/main/java/ch/njol/yggdrasil/JRESerializer.java index 9585681eea6..2f6ae9eefe2 100644 --- a/src/main/java/ch/njol/yggdrasil/JRESerializer.java +++ b/src/main/java/ch/njol/yggdrasil/JRESerializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import com.google.common.collect.ImmutableList; diff --git a/src/main/java/ch/njol/yggdrasil/PseudoEnum.java b/src/main/java/ch/njol/yggdrasil/PseudoEnum.java index e782b393aaf..aeac0c3ed30 100644 --- a/src/main/java/ch/njol/yggdrasil/PseudoEnum.java +++ b/src/main/java/ch/njol/yggdrasil/PseudoEnum.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/yggdrasil/SimpleClassResolver.java b/src/main/java/ch/njol/yggdrasil/SimpleClassResolver.java index 19123306a34..77eeff99653 100644 --- a/src/main/java/ch/njol/yggdrasil/SimpleClassResolver.java +++ b/src/main/java/ch/njol/yggdrasil/SimpleClassResolver.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import com.google.common.collect.BiMap; diff --git a/src/main/java/ch/njol/yggdrasil/Tag.java b/src/main/java/ch/njol/yggdrasil/Tag.java index 8854466b74f..b55c99c2618 100644 --- a/src/main/java/ch/njol/yggdrasil/Tag.java +++ b/src/main/java/ch/njol/yggdrasil/Tag.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/yggdrasil/Yggdrasil.java b/src/main/java/ch/njol/yggdrasil/Yggdrasil.java index d73d27e1341..01db13c4396 100644 --- a/src/main/java/ch/njol/yggdrasil/Yggdrasil.java +++ b/src/main/java/ch/njol/yggdrasil/Yggdrasil.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import ch.njol.yggdrasil.Fields.FieldContext; diff --git a/src/main/java/ch/njol/yggdrasil/YggdrasilException.java b/src/main/java/ch/njol/yggdrasil/YggdrasilException.java index 8ffb86dc39a..8263fa4a28a 100644 --- a/src/main/java/ch/njol/yggdrasil/YggdrasilException.java +++ b/src/main/java/ch/njol/yggdrasil/YggdrasilException.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; /** diff --git a/src/main/java/ch/njol/yggdrasil/YggdrasilID.java b/src/main/java/ch/njol/yggdrasil/YggdrasilID.java index 47b529a174a..233805dc5d7 100644 --- a/src/main/java/ch/njol/yggdrasil/YggdrasilID.java +++ b/src/main/java/ch/njol/yggdrasil/YggdrasilID.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import java.lang.annotation.Documented; diff --git a/src/main/java/ch/njol/yggdrasil/YggdrasilInputStream.java b/src/main/java/ch/njol/yggdrasil/YggdrasilInputStream.java index bb1329f541f..2aa9f97ac8a 100644 --- a/src/main/java/ch/njol/yggdrasil/YggdrasilInputStream.java +++ b/src/main/java/ch/njol/yggdrasil/YggdrasilInputStream.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import ch.njol.yggdrasil.YggdrasilSerializable.YggdrasilExtendedSerializable; diff --git a/src/main/java/ch/njol/yggdrasil/YggdrasilOutputStream.java b/src/main/java/ch/njol/yggdrasil/YggdrasilOutputStream.java index e9f5557e4f9..539ee9bc649 100644 --- a/src/main/java/ch/njol/yggdrasil/YggdrasilOutputStream.java +++ b/src/main/java/ch/njol/yggdrasil/YggdrasilOutputStream.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import ch.njol.yggdrasil.Fields.FieldContext; diff --git a/src/main/java/ch/njol/yggdrasil/YggdrasilSerializable.java b/src/main/java/ch/njol/yggdrasil/YggdrasilSerializable.java index 2d1d511a5da..59933cce1ad 100644 --- a/src/main/java/ch/njol/yggdrasil/YggdrasilSerializable.java +++ b/src/main/java/ch/njol/yggdrasil/YggdrasilSerializable.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import java.io.NotSerializableException; diff --git a/src/main/java/ch/njol/yggdrasil/YggdrasilSerializer.java b/src/main/java/ch/njol/yggdrasil/YggdrasilSerializer.java index f48d187447e..08a90ff67f4 100644 --- a/src/main/java/ch/njol/yggdrasil/YggdrasilSerializer.java +++ b/src/main/java/ch/njol/yggdrasil/YggdrasilSerializer.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/ch/njol/yggdrasil/util/JREFieldHandler.java b/src/main/java/ch/njol/yggdrasil/util/JREFieldHandler.java index 6bff027da85..042c864cf70 100644 --- a/src/main/java/ch/njol/yggdrasil/util/JREFieldHandler.java +++ b/src/main/java/ch/njol/yggdrasil/util/JREFieldHandler.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.yggdrasil.util; import ch.njol.yggdrasil.FieldHandler; diff --git a/src/main/java/org/skriptlang/skript/Skript.java b/src/main/java/org/skriptlang/skript/Skript.java new file mode 100644 index 00000000000..25604cf5cbf --- /dev/null +++ b/src/main/java/org/skriptlang/skript/Skript.java @@ -0,0 +1,56 @@ +package org.skriptlang.skript; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.addon.SkriptAddon; + +import java.util.Collection; + +/** + * The main class for everything related to Skript. + */ +@ApiStatus.Experimental +public interface Skript extends SkriptAddon { + + /** + * Constructs a default implementation of a Skript. + * It makes use of the default implementations of required components. + * @param source The main class of the application creating this Skript. + * Typically, this can be the class invoking this method. + * @param name The name for the Skript to use. + * @return A Skript. + */ + @Contract("_, _ -> new") + static Skript of(Class source, String name) { + return new SkriptImpl(source, name); + } + + /** + * Registers the provided addon with this Skript and loads the provided modules. + * @param source The main class of the application registering this addon. + * Typically, this can be the class invoking this method. + * @param name The name of the addon to register. + */ + @Contract("_, _ -> new") + SkriptAddon registerAddon(Class source, String name); + + /** + * @return An unmodifiable snapshot of addons currently registered with this Skript. + */ + @Unmodifiable Collection addons(); + + /** + * Constructs an unmodifiable view of this Skript. + * That is, the returned Skript will be unable to register new addons + * and the individual addons from {@link #addons()} will be unmodifiable. + * Additionally, it will return unmodifiable views of its inherited {@link SkriptAddon} components. + * @return An unmodifiable view of this Skript. + */ + @Override + @Contract("-> new") + default Skript unmodifiableView() { + return new SkriptImpl.UnmodifiableSkript(this, SkriptAddon.super.unmodifiableView()); + } + +} diff --git a/src/main/java/org/skriptlang/skript/SkriptImpl.java b/src/main/java/org/skriptlang/skript/SkriptImpl.java new file mode 100644 index 00000000000..03b96f503a5 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/SkriptImpl.java @@ -0,0 +1,263 @@ +package org.skriptlang.skript; + +import ch.njol.skript.SkriptAPIException; +import com.google.common.collect.ImmutableSet; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.addon.AddonModule; +import org.skriptlang.skript.addon.SkriptAddon; +import org.skriptlang.skript.localization.Localizer; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Registry; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; + +final class SkriptImpl implements Skript { + + /** + * The addon instance backing this Skript. + */ + private final SkriptAddon addon; + + SkriptImpl(Class source, String name) { + addon = new SkriptAddonImpl(this, source, name, Localizer.of(this)); + storeRegistry(SyntaxRegistry.class, SyntaxRegistry.empty()); + } + + /* + * Registry Management + */ + + private static final Map, Registry> registries = new ConcurrentHashMap<>(); + + @Override + public > void storeRegistry(Class registryClass, R registry) { + registries.put(registryClass, registry); + } + + @Override + public void removeRegistry(Class> registryClass) { + registries.remove(registryClass); + } + + @Override + public boolean hasRegistry(Class> registryClass) { + return registries.containsKey(registryClass); + } + + @Override + public > R registry(Class registryClass) { + //noinspection unchecked + R registry = (R) registries.get(registryClass); + if (registry == null) + throw new NullPointerException("Registry not present for " + registryClass); + return registry; + } + + @Override + public > R registry(Class registryClass, Supplier putIfAbsent) { + //noinspection unchecked + return (R) registries.computeIfAbsent(registryClass, key -> putIfAbsent.get()); + } + + /* + * SkriptAddon Management + */ + + private static final Map addons = new HashMap<>(); + + @Override + public SkriptAddon registerAddon(Class source, String name) { + // make sure an addon is not already registered with this name + SkriptAddon existing = addons.get(name); + if (existing != null) { + throw new SkriptAPIException( + "An addon (provided by '" + existing.source().getName() + "') with the name '" + name + "' is already registered" + ); + } + + SkriptAddon addon = new SkriptAddonImpl(this, source, name, null); + addons.put(name, addon); + return addon; + } + + @Override + public @Unmodifiable Collection addons() { + return ImmutableSet.copyOf(addons.values()); + } + + /* + * SkriptAddon Implementation + */ + + @Override + public Class source() { + return addon.source(); + } + + @Override + public String name() { + return addon.name(); + } + + @Override + public SyntaxRegistry syntaxRegistry() { + return registry(SyntaxRegistry.class); + } + + @Override + public Localizer localizer() { + return addon.localizer(); + } + + @Override + public void loadModules(AddonModule... modules) { + addon.loadModules(modules); + } + + private static final class SkriptAddonImpl implements SkriptAddon { + + private final Skript skript; + private final Class source; + private final String name; + private final Localizer localizer; + + SkriptAddonImpl(Skript skript, Class source, String name, @Nullable Localizer localizer) { + this.skript = skript; + this.source = source; + this.name = name; + this.localizer = localizer == null ? Localizer.of(this) : localizer; + } + + @Override + public Class source() { + return source; + } + + @Override + public String name() { + return name; + } + + @Override + public > void storeRegistry(Class registryClass, R registry) { + skript.storeRegistry(registryClass, registry); + } + + @Override + public void removeRegistry(Class> registryClass) { + skript.removeRegistry(registryClass); + } + + @Override + public boolean hasRegistry(Class> registryClass) { + return skript.hasRegistry(registryClass); + } + + @Override + public > R registry(Class registryClass) { + return skript.registry(registryClass); + } + + @Override + public > R registry(Class registryClass, Supplier putIfAbsent) { + return skript.registry(registryClass, putIfAbsent); + } + + @Override + public SyntaxRegistry syntaxRegistry() { + return skript.syntaxRegistry(); + } + + @Override + public Localizer localizer() { + return localizer; + } + + } + + /* + * ViewProvider Implementation + */ + + static final class UnmodifiableSkript implements Skript { + + private final Skript skript; + private final SkriptAddon unmodifiableAddon; + + UnmodifiableSkript(Skript skript, SkriptAddon unmodifiableAddon) { + this.skript = skript; + this.unmodifiableAddon = unmodifiableAddon; + } + + @Override + public SkriptAddon registerAddon(Class source, String name) { + throw new UnsupportedOperationException("Cannot register addons using an unmodifiable Skript"); + } + + @Override + public @Unmodifiable Collection addons() { + ImmutableSet.Builder addons = ImmutableSet.builder(); + skript.addons().stream() + .map(SkriptAddon::unmodifiableView) + .forEach(addons::add); + return addons.build(); + } + + @Override + public Class source() { + return skript.source(); + } + + @Override + public String name() { + return skript.name(); + } + + @Override + public > void storeRegistry(Class registryClass, R registry) { + unmodifiableAddon.storeRegistry(registryClass, registry); + } + + @Override + public void removeRegistry(Class> registryClass) { + unmodifiableAddon.removeRegistry(registryClass); + } + + @Override + public boolean hasRegistry(Class> registryClass) { + return unmodifiableAddon.hasRegistry(registryClass); + } + + @Override + public > R registry(Class registryClass) { + return unmodifiableAddon.registry(registryClass); + } + + @Override + public > R registry(Class registryClass, Supplier putIfAbsent) { + return unmodifiableAddon.registry(registryClass, putIfAbsent); + } + + @Override + public SyntaxRegistry syntaxRegistry() { + return unmodifiableAddon.syntaxRegistry(); + } + + @Override + public Localizer localizer() { + return unmodifiableAddon.localizer(); + } + + @Override + public void loadModules(AddonModule... modules) { + unmodifiableAddon.loadModules(modules); + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/addon/AddonModule.java b/src/main/java/org/skriptlang/skript/addon/AddonModule.java new file mode 100644 index 00000000000..243d51b730b --- /dev/null +++ b/src/main/java/org/skriptlang/skript/addon/AddonModule.java @@ -0,0 +1,36 @@ +package org.skriptlang.skript.addon; + +import org.jetbrains.annotations.ApiStatus; +import org.skriptlang.skript.Skript; + +/** + * A module is a component of a {@link SkriptAddon} used for registering syntax and other {@link Skript} components. + *
+ * Modules have two loading phases: {@link #init(SkriptAddon)} followed by {@link #load(SkriptAddon)}. + *
+ * The init phase should be used for loading components that are needed first or that may be used by other modules, + * such as class infos (think numeric types that are used everywhere). + *
+ * The load phase should be used for loading components more specific to the module, such as syntax. + * @see SkriptAddon#loadModules(AddonModule...) + */ +@FunctionalInterface +@ApiStatus.Experimental +public interface AddonModule { + + /** + * Used for loading the components of this module that are needed first or by other modules (e.g. class infos). + * This method will always be called before {@link #load(SkriptAddon)}. + * @param addon The addon this module belongs to. + * @see #load(SkriptAddon) + */ + default void init(SkriptAddon addon) { } + + /** + * Used for loading the components (e.g. syntax) of this module. + * @param addon The addon this module belongs to. + * @see #init(SkriptAddon) + */ + void load(SkriptAddon addon); + +} diff --git a/src/main/java/org/skriptlang/skript/addon/SkriptAddon.java b/src/main/java/org/skriptlang/skript/addon/SkriptAddon.java new file mode 100644 index 00000000000..13e47180ff3 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/addon/SkriptAddon.java @@ -0,0 +1,112 @@ +package org.skriptlang.skript.addon; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.skriptlang.skript.Skript; +import org.skriptlang.skript.localization.Localizer; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Registry; +import org.skriptlang.skript.util.ViewProvider; + +import java.util.function.Supplier; + +/** + * A Skript addon is an extension to Skript that expands its features. + * Typically, an addon instance may be obtained through {@link Skript#registerAddon(Class, String)}. + */ +@ApiStatus.Experimental +public interface SkriptAddon extends ViewProvider { + + /** + * @return A class from the application that registered this addon. + * Typically, this is the main class or the specific class in which registration occurred. + */ + Class source(); + + /** + * @return The name of this addon. + */ + String name(); + + /** + * Stores a registry under registryClass. + * If a registry is already stored under registryClass, it will be replaced. + * @param registryClass The class (key) to store registry under. + * @param registry The registry to store. + * @param The type of registry. + */ + > void storeRegistry(Class registryClass, R registry); + + /** + * Removes the registry stored under registryClass. + * It is safe to call this method even if a registry is not stored under registryClass. + * @param registryClass The class (key) that the registry to remove is under. + */ + void removeRegistry(Class> registryClass); + + /** + * Determines whether a registry has been stored under registryClass. + * @param registryClass The class (key) to search for a registry under. + * @return Whether a registry is stored under registryClass. + */ + boolean hasRegistry(Class> registryClass); + + /** + * Obtains the registry stored under registryClass. + * This method will never return null, meaning it may be necessary to call {@link #hasRegistry(Class)} + * if you are not sure whether the registry you need exists. + * @param registryClass The class (key) that the registry is stored under. + * @return The registry stored under registryClass. + * @param The type of registry. + */ + > R registry(Class registryClass); + + /** + * Searches for a registry stored under registryClass. + * If the search fails, putIfAbsent will be used to get, store, and return a registry of the requested type. + * @param registryClass The class (key) to search for a registry under. + * @param putIfAbsent A supplier to use for creating an instance of the desired type of registry if one + * is not already stored under registryClass. + * @return The registry stored under registryClass or created from putIfAbsent. + * @param The type of registry. + */ + > R registry(Class registryClass, Supplier putIfAbsent); + + /** + * @return A syntax registry for this addon's syntax. + */ + SyntaxRegistry syntaxRegistry(); + + /** + * @return A localizer for this addon's localizations. + */ + Localizer localizer(); + + /** + * A helper method for loading addon modules. + * Modules will be loaded as described by {@link AddonModule}. + * @param modules The modules to load. + */ + default void loadModules(AddonModule... modules) { + for (AddonModule module : modules) { + module.init(this); + } + for (AddonModule module : modules) { + module.load(this); + } + } + + /** + * Constructs an unmodifiable view of this addon. + * That is, the returned addon will return unmodifiable views of its {@link #syntaxRegistry()} and {@link #localizer()}. + * @return An unmodifiable view of this addon. + * @see SyntaxRegistry#unmodifiableView() + * @see Localizer#unmodifiableView() + */ + @Override + @Contract("-> new") + default SkriptAddon unmodifiableView() { + return new SkriptAddonImpl.UnmodifiableAddon(this); + } + +} diff --git a/src/main/java/org/skriptlang/skript/addon/SkriptAddonImpl.java b/src/main/java/org/skriptlang/skript/addon/SkriptAddonImpl.java new file mode 100644 index 00000000000..33af5c65b74 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/addon/SkriptAddonImpl.java @@ -0,0 +1,79 @@ +package org.skriptlang.skript.addon; + +import org.skriptlang.skript.localization.Localizer; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.util.Registry; +import org.skriptlang.skript.util.ViewProvider; + +import java.util.function.Supplier; + +class SkriptAddonImpl { + + static class UnmodifiableAddon implements SkriptAddon { + + private final SkriptAddon addon; + private final Localizer unmodifiableLocalizer; + + UnmodifiableAddon(SkriptAddon addon) { + this.addon = addon; + this.unmodifiableLocalizer = addon.localizer().unmodifiableView(); + } + + @Override + public Class source() { + return addon.source(); + } + + @Override + public String name() { + return addon.name(); + } + + @Override + public > void storeRegistry(Class registryClass, R registry) { + throw new UnsupportedOperationException("Cannot store registries on an unmodifiable addon"); + } + + @Override + public void removeRegistry(Class> registryClass) { + throw new UnsupportedOperationException("Cannot remove registries from an unmodifiable addon"); + } + + @Override + public boolean hasRegistry(Class> registryClass) { + return addon.hasRegistry(registryClass); + } + + @Override + public > R registry(Class registryClass) { + R registry = addon.registry(registryClass); + if (registry instanceof ViewProvider) { + //noinspection unchecked + registry = ((ViewProvider) registry).unmodifiableView(); + } + return registry; + } + + @Override + public > R registry(Class registryClass, Supplier putIfAbsent) { + throw new UnsupportedOperationException("Cannot store registries on an unmodifiable addon"); + } + + @Override + public SyntaxRegistry syntaxRegistry() { + return addon.syntaxRegistry().unmodifiableView(); + } + + @Override + public Localizer localizer() { + return unmodifiableLocalizer; + } + + @Override + public void loadModules(AddonModule... modules) { + throw new UnsupportedOperationException("Cannot load modules using an unmodifiable addon"); + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/furnace/FurnaceModule.java b/src/main/java/org/skriptlang/skript/bukkit/furnace/FurnaceModule.java new file mode 100644 index 00000000000..0a1f50286ff --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/furnace/FurnaceModule.java @@ -0,0 +1,12 @@ +package org.skriptlang.skript.bukkit.furnace; + +import ch.njol.skript.Skript; +import java.io.IOException; + +public class FurnaceModule { + + public static void load() throws IOException{ + Skript.getAddonInstance().loadClasses("org.skriptlang.skript.bukkit.furnace", "elements"); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/EvtFurnace.java b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/EvtFurnace.java new file mode 100644 index 00000000000..5367ebc57c0 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/EvtFurnace.java @@ -0,0 +1,115 @@ +package org.skriptlang.skript.bukkit.furnace.elements; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.lang.Literal; +import ch.njol.skript.lang.SkriptEvent; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.registrations.Classes; +import org.bukkit.event.Event; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.FurnaceStartSmeltEvent; +import org.jetbrains.annotations.Nullable; + +public class EvtFurnace extends SkriptEvent { + + static { + Skript.registerEvent("Smelt", EvtFurnace.class, FurnaceSmeltEvent.class, + "[furnace] [ore] smelt[ed|ing] [of %-itemtypes%]", + "[furnace] smelt[ed|ing] of ore") + .description("Called when a furnace smelts an item in its input slot.") + .examples( + "on smelt:", + "\tclear the smelted item", + "on smelt of raw iron:", + "\tbroadcast smelted item", + "\tset the smelted item to iron block" + ) + .since("1.0, INSERT VERSION (specific item)"); + + Skript.registerEvent("Fuel Burn", EvtFurnace.class, FurnaceBurnEvent.class, "[furnace] fuel burn[ing] [of %-itemtypes%]") + .description("Called when a furnace burns an item from its fuel slot.") + .examples( + "on fuel burning:", + "\tbroadcast fuel burned", + "\tif burned fuel is coal:", + "\t\tadd 20 seconds to burn time" + ) + .since("1.0, INSERT VERSION (specific item)"); + + Skript.registerEvent("Furnace Item Extract", EvtFurnace.class, FurnaceExtractEvent.class, "furnace [item] extract[ion] [of %-itemtypes%]") + .description("Called when a player takes any item out of the furnace.") + .examples( + "on furnace extract:", + "\tif event-items is an iron ingot:", + "\t\tremove event-items from event-player's inventory" + ) + .since("INSERT VERSION"); + + Skript.registerEvent("Start Smelt", EvtFurnace.class, FurnaceStartSmeltEvent.class, + "[furnace] start [of] smelt[ing] [[of] %-itemtypes%]", + "[furnace] smelt[ing] start [of %-itemtypes%]") + .description("Called when a furnace starts smelting an item in its ore slot.") + .examples( + "on smelting start:", + "\tif the smelting item is raw iron:", + "\t\tset total cook time to 1 second", + "on smelting start of raw iron:", + "\tadd 20 seconds to total cook time" + ) + .since("INSERT VERSION"); + } + + private @Nullable Literal types; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Literal[] exprs, int matchedPattern, ParseResult parseResult) { + if (exprs[0] != null) + types = (Literal) exprs[0]; + return true; + } + + @Override + public boolean check(Event event) { + if (types == null) + return true; + + ItemType item; + + if (event instanceof FurnaceSmeltEvent smeltEvent) { + item = new ItemType(smeltEvent.getSource()); + } else if (event instanceof FurnaceBurnEvent burnEvent) { + item = new ItemType(burnEvent.getFuel()); + } else if (event instanceof FurnaceExtractEvent extractEvent) { + item = new ItemType(extractEvent.getItemType()); + } else if (event instanceof FurnaceStartSmeltEvent startEvent) { + item = new ItemType(startEvent.getSource()); + } else { + assert false; + return false; + } + + return types.check(event, itemType -> itemType.isSupertypeOf(item)); + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + String result = ""; + if (event instanceof FurnaceSmeltEvent) { + result = "smelt"; + } else if (event instanceof FurnaceBurnEvent) { + result = "burn"; + } else if (event instanceof FurnaceExtractEvent) { + result = "extract"; + } else if (event instanceof FurnaceStartSmeltEvent) { + result = "start smelt"; + } else { + throw new IllegalStateException("Unexpected event: " + event); + } + return result + " of " + Classes.toString(types); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceEventItems.java b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceEventItems.java new file mode 100644 index 00000000000..efa3d19f171 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceEventItems.java @@ -0,0 +1,137 @@ +package org.skriptlang.skript.bukkit.furnace.elements; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.*; +import ch.njol.skript.expressions.base.EventValueExpression; +import ch.njol.skript.expressions.base.PropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.Event; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.FurnaceStartSmeltEvent; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Nullable; + +@Name("Furnace Event Items") +@Description({ + "Represents the different items in furnace events.", + "Only 'smelting item' can be changed." +}) +@Examples({ + "on furnace smelt:", + "\tbroadcast smelted item", + "\t# Or 'result'", + "on furnace extract:", + "\tbroadcast extracted item", + "on fuel burn:", + "\tbroadcast burned fuel", + "on smelting start:", + "\tbroadcast smelting item", + "\tclear smelting item" +}) +@Events({"smelt", "fuel burn", "smelting start", "furnace extract"}) +@Since("INSERT VERSION") +public class ExprFurnaceEventItems extends PropertyExpression { + + enum FurnaceValues { + SMELTED("(smelted item|result[ item])", "smelted item", FurnaceSmeltEvent.class, "'smelted item' can only be used in a smelting event."), + EXTRACTED("extracted item[s]", "extracted item", FurnaceExtractEvent.class, "'extracted item' can only be used in a furnace extract event."), + SMELTING("smelting item", "smelting item", FurnaceStartSmeltEvent.class, "'smelting item' can only be used in a start smelting event"), + BURNED("burned (fuel|item)", "burned fuel item", FurnaceBurnEvent.class, "'burned fuel' can only be used in a fuel burning event."); + + private String pattern, error, toString; + private Class clazz; + + FurnaceValues(String pattern, String toString, Class clazz, String error) { + this.pattern = "[the] " + pattern; + this.clazz = clazz; + this.error = error; + this.toString = toString; + } + + } + + private static final FurnaceValues[] FURNACE_VALUES = FurnaceValues.values(); + + static { + int size = FURNACE_VALUES.length; + String[] patterns = new String[size]; + for (FurnaceValues value : FURNACE_VALUES) { + patterns[value.ordinal()] = value.pattern; + } + + Skript.registerExpression(ExprFurnaceEventItems.class, ItemStack.class, ExpressionType.PROPERTY, patterns); + } + + private FurnaceValues type; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + type = FURNACE_VALUES[matchedPattern]; + if (!getParser().isCurrentEvent(type.clazz)) { + Skript.error(type.error); + return false; + } + setExpr(new EventValueExpression<>(Block.class)); + return true; + } + + @Override + protected ItemStack @Nullable [] get(Event event, Block[] source) { + return new ItemStack[]{switch (type) { + case SMELTING -> ((FurnaceStartSmeltEvent) event).getSource(); + case BURNED -> ((FurnaceBurnEvent) event).getFuel(); + case SMELTED -> ((FurnaceSmeltEvent) event).getResult(); + case EXTRACTED -> { + FurnaceExtractEvent extractEvent = (FurnaceExtractEvent) event; + yield new ItemStack(extractEvent.getItemType(), extractEvent.getItemAmount()); + } + }}; + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (type != FurnaceValues.SMELTED) + return null; + if (mode != ChangeMode.SET && mode != ChangeMode.DELETE) + return null; + return CollectionUtils.array(ItemStack.class); + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (!(event instanceof FurnaceSmeltEvent smeltEvent)) + return; + + if (mode == ChangeMode.SET) { + smeltEvent.setResult((ItemStack) delta[0]); + } else if (mode == ChangeMode.DELETE) { + smeltEvent.setResult(ItemStack.of(Material.AIR)); + } + + } + + @Override + public boolean isSingle() { + return true; + } + + @Override + public Class getReturnType() { + return ItemStack.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return type.toString; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceSlot.java b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceSlot.java new file mode 100644 index 00000000000..8fd42c23d0c --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceSlot.java @@ -0,0 +1,229 @@ +package org.skriptlang.skript.bukkit.furnace.elements; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Events; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.effects.Delay; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.util.SimpleExpression; +import ch.njol.skript.registrations.EventValues; +import ch.njol.skript.util.slot.InventorySlot; +import ch.njol.skript.util.slot.Slot; +import ch.njol.util.Kleenean; +import ch.njol.util.Math2; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.Furnace; +import org.bukkit.event.Event; +import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.FurnaceStartSmeltEvent; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +@Name("Furnace Slot") +@Description({ + "A slot of a furnace, i.e. either the ore, fuel or result slot." +}) +@Examples({ + "set the fuel slot of the clicked block to a lava bucket", + "set the block's ore slot to 64 iron ore", + "clear the result slot of the block", + "on smelt:", + "\tif the fuel slot is charcoal:", + "\t\tadd 5 seconds to the burn time" +}) +@Events({"smelt", "fuel burn"}) +@Since("1.0, 2.8.0 (syntax rework)") +public class ExprFurnaceSlot extends SimpleExpression { + + private enum FurnaceSlot { + INPUT("(ore|input)", "input"), + FUEL("fuel", "fuel"), + OUTPUT("(result|output)", "output"); + + private String pattern, toString; + + FurnaceSlot(String pattern, String toString) { + this.pattern = pattern; + this.toString = toString; + } + } + + private static final FurnaceSlot[] furnaceSlots = FurnaceSlot.values(); + + static { + String[] patterns = new String[furnaceSlots.length * 2]; + for (FurnaceSlot slot : furnaceSlots) { + patterns[2 * slot.ordinal()] = "[the] " + slot.pattern + " slot[s] [of %blocks%]"; + patterns[2 * slot.ordinal() + 1] = "%blocks%'[s] " + slot.pattern + " slot[s]"; + } + Skript.registerExpression(ExprFurnaceSlot.class, Slot.class, ExpressionType.PROPERTY, patterns); + } + + + private @Nullable Expression blocks; + private FurnaceSlot selectedSlot; + private boolean isEvent; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + selectedSlot = furnaceSlots[(int) Math2.floor(matchedPattern / 2)]; + if (exprs[0] != null) { + //noinspection unchecked + blocks = (Expression) exprs[0]; + } else { + if (!getParser().isCurrentEvent(FurnaceBurnEvent.class, FurnaceStartSmeltEvent.class, FurnaceExtractEvent.class, FurnaceSmeltEvent.class)) { + Skript.error("There's no furnace in a " + getParser().getCurrentEventName() + " event."); + return false; + } + isEvent = true; + } + return true; + } + + @Override + protected Slot @Nullable [] get(Event event) { + Block[] blocks; + if (isEvent) { + blocks = new Block[1]; + if (event instanceof BlockEvent blockEvent) { + blocks[0] = blockEvent.getBlock(); + } else { + return new Slot[0]; + } + } else { + assert this.blocks != null; + blocks = this.blocks.getArray(event); + } + + List slots = new ArrayList<>(); + for (Block block : blocks) { + BlockState state = block.getState(); + if (!(state instanceof Furnace)) + continue; + FurnaceInventory furnaceInventory = ((Furnace) state).getInventory(); + if (isEvent && !Delay.isDelayed(event)) { + slots.add(new FurnaceEventSlot(event, furnaceInventory)); + } else { + slots.add(new InventorySlot(furnaceInventory, selectedSlot.ordinal())); + } + } + return slots.toArray(new Slot[0]); + } + + @Override + public boolean isSingle() { + if (isEvent) + return true; + assert blocks != null; + return blocks.isSingle(); + } + + @Override + public Class getReturnType() { + return InventorySlot.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return selectedSlot.toString + " slot of " + (isEvent ? event.getEventName() : blocks.toString(event, debug)); + } + + @Override + public boolean setTime(int time) { + if (isEvent) { // getExpr will be null + if (selectedSlot == FurnaceSlot.FUEL) + return setTime(time, FurnaceBurnEvent.class); + return setTime(time, FurnaceSmeltEvent.class); + } + return false; + } + + private final class FurnaceEventSlot extends InventorySlot { + + private final Event event; + + public FurnaceEventSlot(Event event, FurnaceInventory furnaceInventory) { + super(furnaceInventory, selectedSlot.ordinal()); + this.event = event; + } + + @Override + public @Nullable ItemStack getItem() { + return switch (selectedSlot) { + case INPUT -> { + if (event instanceof FurnaceSmeltEvent furnaceSmeltEvent) { + ItemStack source = furnaceSmeltEvent.getSource().clone(); + if (getTime() != EventValues.TIME_FUTURE) + yield source; + source.setAmount(source.getAmount() - 1); + yield source; + } + yield super.getItem(); + } + case FUEL -> { + if (event instanceof FurnaceBurnEvent furnaceBurnEvent) { + ItemStack fuel = furnaceBurnEvent.getFuel().clone(); + if (getTime() != EventValues.TIME_FUTURE) + yield fuel; + // a single lava bucket becomes an empty bucket + // see https://minecraft.wiki/w/Smelting#Fuel + // this is declared here because setting the amount to 0 may cause the ItemStack to become AIR + Material newMaterial = fuel.getType() == Material.LAVA_BUCKET ? Material.BUCKET : Material.AIR; + fuel.setAmount(fuel.getAmount() - 1); + if (fuel.getAmount() == 0) + fuel = new ItemStack(newMaterial); + yield fuel; + } + yield super.getItem(); + } + case OUTPUT -> { + if (event instanceof FurnaceSmeltEvent furnaceSmeltEvent) { + ItemStack result = furnaceSmeltEvent.getResult().clone(); + ItemStack currentResult = ((FurnaceInventory) getInventory()).getResult(); + if (currentResult != null) + currentResult = currentResult.clone(); + if (getTime() != EventValues.TIME_FUTURE) { // 'past result slot' and 'result slot' + yield currentResult; + } else if (currentResult != null && currentResult.isSimilar(result)) { // 'future result slot' + currentResult.setAmount(currentResult.getAmount() + result.getAmount()); + yield currentResult; + } else { + yield result; // 'the result' + } + } + yield super.getItem(); + } + }; + } + + @Override + public void setItem(@Nullable ItemStack item) { + if (selectedSlot == FurnaceSlot.OUTPUT && event instanceof FurnaceSmeltEvent furnaceSmeltEvent) { + furnaceSmeltEvent.setResult(item != null ? item : new ItemStack(Material.AIR)); + } else { + if (getTime() == EventValues.TIME_FUTURE) { // Since this is a future expression, run it AFTER the event + Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), () -> FurnaceEventSlot.super.setItem(item)); + } else { + super.setItem(item); + } + } + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceTime.java b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceTime.java new file mode 100644 index 00000000000..af4d51e94b4 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/furnace/elements/ExprFurnaceTime.java @@ -0,0 +1,207 @@ +package org.skriptlang.skript.bukkit.furnace.elements; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.*; +import ch.njol.skript.expressions.base.EventValueExpression; +import ch.njol.skript.expressions.base.PropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.util.Timespan; +import ch.njol.util.Kleenean; +import ch.njol.util.Math2; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.block.Block; +import org.bukkit.block.Furnace; +import org.bukkit.event.Event; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.FurnaceStartSmeltEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +@Name("Furnace Times") +@Description({ + "The cook time, total cook time, and burn time of a furnace. Can be changed.", + "
    ", + "
  • cook time: The amount of time an item has been smelting for.
  • ", + "
  • total cook time: The amount of time required to finish smelting an item.
  • ", + "
  • burn time: The amount of time left for the current fuel until consumption of another fuel item.
  • ", + "
" +}) +@Examples({ + "set the cooking time of {_block} to 10", + "set the total cooking time of {_block} to 50", + "set the fuel burning time of {_block} to 100", + "on smelt:", + "\tif the fuel slot is charcoal:", + "\t\tadd 5 seconds to the fuel burn time" +}) +@Since("INSERT VERSION") +public class ExprFurnaceTime extends PropertyExpression { + + enum FurnaceExpressions { + COOKTIME("cook[ing] time", "cook time"), + TOTALCOOKTIME("total cook[ing] time", "total cook time"), + BURNTIME("fuel burn[ing] time", "fuel burn time"); + + private String pattern, toString; + + FurnaceExpressions(String pattern, String toString) { + this.pattern = pattern; + this.toString = toString; + } + + } + + private static final FurnaceExpressions[] furnaceExprs = FurnaceExpressions.values(); + + static { + + int size = furnaceExprs.length; + String[] patterns = new String[size * 2]; + for (FurnaceExpressions value : furnaceExprs) { + patterns[2 * value.ordinal()] = "[the] [furnace] " + value.pattern + " [of %blocks%]"; + patterns[2 * value.ordinal() + 1] = "%blocks%'[s]" + value.pattern; + } + + Skript.registerExpression(ExprFurnaceTime.class, Timespan.class, ExpressionType.PROPERTY, patterns); + } + + private FurnaceExpressions type; + private boolean explicitlyBlock = false; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + type = furnaceExprs[matchedPattern / 2]; + if (exprs[0] != null) { + explicitlyBlock = true; + //noinspection unchecked + setExpr((Expression) exprs[0]); + } else { + if (!getParser().isCurrentEvent(FurnaceBurnEvent.class, FurnaceStartSmeltEvent.class, FurnaceExtractEvent.class, FurnaceSmeltEvent.class)) { + Skript.error("There's no furnace in a '" + getParser().getCurrentEventName() + "' event."); + return false; + } + explicitlyBlock = false; + setExpr(new EventValueExpression<>(Block.class)); + } + return true; + } + + @Override + protected Timespan @Nullable [] get(Event event, Block[] source) { + return get(source, block -> { + if (block == null || !(block.getState() instanceof Furnace furnace)) + return null; + switch (type) { + case COOKTIME -> { + return new Timespan(Timespan.TimePeriod.TICK, (int) furnace.getCookTime()); + } + case TOTALCOOKTIME -> { + if (event instanceof FurnaceStartSmeltEvent startEvent && block.equals(startEvent.getBlock())) { + return new Timespan(Timespan.TimePeriod.TICK, startEvent.getTotalCookTime()); + } else { + return new Timespan(Timespan.TimePeriod.TICK, furnace.getCookTimeTotal()); + } + } + case BURNTIME -> { + if (event instanceof FurnaceBurnEvent burnEvent && block.equals(burnEvent.getBlock())) { + return new Timespan(Timespan.TimePeriod.TICK, burnEvent.getBurnTime()); + } else { + return new Timespan(Timespan.TimePeriod.TICK, (int) furnace.getBurnTime()); + } + } + } + return null; + }); + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (mode == ChangeMode.REMOVE_ALL || mode == ChangeMode.RESET) + return null; + + return CollectionUtils.array(Timespan.class); + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + int providedTime = 0; + if (delta != null && delta[0] instanceof Timespan span) + providedTime = (int) span.get(Timespan.TimePeriod.TICK); + int finalTime = providedTime; + + Function calculateTime = switch (mode) { + case SET -> time -> finalTime; + case ADD -> time -> Math2.fit(0, time + finalTime, Integer.MAX_VALUE); + case REMOVE -> time -> Math2.fit(0, time - finalTime, Integer.MAX_VALUE); + case DELETE -> time -> 0; + default -> throw new IllegalStateException("Unexpected value: " + mode); + }; + Function calculateTimeShort = switch (mode) { + case SET -> time -> (short) finalTime; + case ADD -> time -> (short) Math2.fit(0, time + finalTime, Short.MAX_VALUE); + case REMOVE -> time -> (short) Math2.fit(0, time - finalTime, Short.MAX_VALUE); + case DELETE -> time -> (short) 0; + default -> throw new IllegalStateException("Unexpected value: " + mode); + }; + + switch (type) { + case COOKTIME -> changeFurnaces(event, furnace -> change(furnace::setCookTime, furnace::getCookTime, calculateTimeShort)); + case TOTALCOOKTIME -> { + if (!explicitlyBlock && event instanceof FurnaceStartSmeltEvent smeltEvent) { + change(smeltEvent::setTotalCookTime, smeltEvent::getTotalCookTime, calculateTime); + } else { + changeFurnaces(event, furnace -> change(furnace::setCookTimeTotal, furnace::getCookTimeTotal, calculateTime)); + } + } + case BURNTIME -> { + if (!explicitlyBlock && event instanceof FurnaceBurnEvent burnEvent) { + change(burnEvent::setBurnTime, burnEvent::getBurnTime, calculateTime); + } else { + changeFurnaces(event, furnace -> change(furnace::setBurnTime, furnace::getBurnTime, calculateTimeShort)); + } + } + } + } + + /** + * Handler for setting data of furnace blocks + * @param event Event + * @param changer The consumer used to apply to the furnace blocks + */ + private void changeFurnaces(Event event, Consumer changer) { + for (Block block : getExpr().getArray(event)) { + Furnace furnace = (Furnace) block.getState(); + changer.accept(furnace); + furnace.update(true); + } + } + + private static void change(@NotNull Consumer set, @NotNull Supplier get, @NotNull Function calculateTime) { + set.accept(calculateTime.apply(get.get())); + } + + @Override + public boolean isSingle() { + return getExpr().isSingle(); + } + + @Override + public Class getReturnType() { + return Timespan.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return type.toString + " of " + getExpr().toString(event, debug); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextCreateEvent.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextCreateEvent.java new file mode 100644 index 00000000000..4f00c85ed74 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextCreateEvent.java @@ -0,0 +1,27 @@ +package org.skriptlang.skript.bukkit.loottables; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.skriptlang.skript.bukkit.loottables.elements.expressions.ExprSecCreateLootContext; + +/** + * The event used in the {@link ExprSecCreateLootContext} section. + */ +public class LootContextCreateEvent extends Event { + + private final LootContextWrapper contextWrapper; + + public LootContextCreateEvent(LootContextWrapper context) { + this.contextWrapper = context; + } + + public LootContextWrapper getContextWrapper() { + return contextWrapper; + } + + @Override + public HandlerList getHandlers() { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java new file mode 100644 index 00000000000..e2afc7ed2c3 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootContextWrapper.java @@ -0,0 +1,112 @@ +package org.skriptlang.skript.bukkit.loottables; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.loot.LootContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Wrapper for a LootContext.Builder to allow easier creation of LootContexts. + */ +public class LootContextWrapper { + + private @NotNull Location location; + private transient @Nullable LootContext cachedLootContext; + private @Nullable Player killer; + private @Nullable Entity entity; + private float luck; + + /** + * Creates a new LootContextWrapper at the given location. + * @param location the location of the LootContext. + */ + public LootContextWrapper(@NotNull Location location) { + this.location = location; + } + + /** + * Gets the LootContext from the wrapper. + * @return the LootContext. + */ + public LootContext getContext() { + if (cachedLootContext == null) + cachedLootContext = new LootContext.Builder(location) + .killer(killer) + .lootedEntity(entity) + .luck(luck) + .build(); + + return cachedLootContext; + } + + /** + * Sets the location of the LootContext. + * @param location the location. + */ + public void setLocation(@NotNull Location location) { + this.location = location; + cachedLootContext = null; + } + + /** + * Sets the killer of the LootContext. + * @param killer the killer. + */ + public void setKiller(@Nullable Player killer) { + this.killer = killer; + cachedLootContext = null; + } + + /** + * Sets the entity of the LootContext. + * @param entity the entity. + */ + public void setEntity(@Nullable Entity entity) { + this.entity = entity; + cachedLootContext = null; + } + + /** + * Sets the luck of the LootContext. + * @param luck the luck value. + */ + public void setLuck(float luck) { + this.luck = luck; + cachedLootContext = null; + } + + /** + * Gets the location of the LootContext. + * @return the location. + */ + public Location getLocation() { + return location; + } + + /** + * Gets the killer of the LootContext. + * @return the killer. + */ + public @Nullable Player getKiller() { + return killer; + } + + /** + * Gets the entity of the LootContext. + * @return the entity. + */ + public @Nullable Entity getEntity() { + return entity; + } + + /** + * Gets the luck of the LootContext. + * @return the luck value. + */ + public float getLuck() { + return luck; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableModule.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableModule.java new file mode 100644 index 00000000000..504ab269889 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableModule.java @@ -0,0 +1,127 @@ +package org.skriptlang.skript.bukkit.loottables; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.ClassInfo; +import ch.njol.skript.classes.Parser; +import ch.njol.skript.expressions.base.EventValueExpression; +import ch.njol.skript.lang.ParseContext; +import ch.njol.skript.lang.util.SimpleEvent; +import ch.njol.skript.registrations.Classes; +import ch.njol.skript.registrations.EventValues; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Entity; +import org.bukkit.event.world.LootGenerateEvent; +import org.bukkit.loot.LootContext; +import org.bukkit.loot.LootTable; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; + +public class LootTableModule { + + public static void load() throws IOException { + + // --- CLASSES --- // + + Classes.registerClass(new ClassInfo<>(LootTable.class, "loottable") + .user("loot ?tables?") + .name("Loot Table") + .description( + "Loot tables represent what items should be in naturally generated containers, " + + "what items should be dropped when killing a mob, or what items can be fished.", + "You can find more information about this in https://minecraft.wiki/w/Loot_table" + ) + .since("INSERT VERSION") + .parser(new Parser<>() { + @Override + public @Nullable LootTable parse(String key, ParseContext context) { + NamespacedKey namespacedKey = NamespacedKey.fromString(key); + if (namespacedKey == null) + return null; + return Bukkit.getLootTable(namespacedKey); + } + + @Override + public String toString(LootTable o, int flags) { + return "loot table \"" + o.getKey() + '\"'; + } + + @Override + public String toVariableNameString(LootTable o) { + return "loot table:" + o.getKey(); + } + }) + ); + + Classes.registerClass(new ClassInfo<>(LootContext.class, "lootcontext") + .user("loot ?contexts?") + .name("Loot Context") + .description( + "Represents additional information a loot table can use to modify its generated loot.", + "", + "Some loot tables will require some values (i.e. looter, location, looted entity) " + + "in a loot context when generating loot whereas others may not.", + "For example, the loot table of a simple dungeon chest will only require a location, " + + "whereas the loot table of a cow will require a looting player, looted entity, and location.", + "You can find more information about this in https://minecraft.wiki/w/Loot_context" + ) + .since("INSERT VERSION") + .defaultExpression(new EventValueExpression<>(LootContext.class)) + .parser(new Parser<>() { + @Override + public boolean canParse(ParseContext context) { + return false; + } + + @Override + public String toString(LootContext context, int flags) { + StringBuilder builder = new StringBuilder("loot context at ") + .append(Classes.toString(context.getLocation())); + + if (context.getLootedEntity() != null) + builder.append(" with entity ").append(Classes.toString(context.getLootedEntity())); + if (context.getKiller() != null) + builder.append(" with killer ").append(Classes.toString(context.getKiller())); + if (context.getLuck() != 0) + builder.append(" with luck ").append(context.getLuck()); + + return builder.toString(); + } + + @Override + public String toVariableNameString(LootContext context) { + return "loot context:" + context.hashCode(); + } + }) + ); + + Skript.getAddonInstance().loadClasses("org.skriptlang.skript.bukkit.loottables", "elements"); + + // --- SIMPLE EVENTS --- // + + Skript.registerEvent("Loot Generate", SimpleEvent.class, LootGenerateEvent.class, "loot generat(e|ing)") + .description( + "Called when a loot table of an inventory is generated in the world.", + "For example, when opening a shipwreck chest." + ) + .examples( + "on loot generate:", + "\tchance of 10%", + "\tadd 64 diamonds to the loot", + "\tsend \"You hit the jackpot at %event-location%!\"" + ) + .since("2.7") + .requiredPlugins("MC 1.16+"); + + // --- EVENT VALUES --- // + + // LootGenerateEvent + EventValues.registerEventValue(LootGenerateEvent.class, Entity.class, LootGenerateEvent::getEntity); + EventValues.registerEventValue(LootGenerateEvent.class, Location.class, event -> event.getLootContext().getLocation()); + EventValues.registerEventValue(LootGenerateEvent.class, LootTable.class, LootGenerateEvent::getLootTable); + EventValues.registerEventValue(LootGenerateEvent.class, LootContext.class, LootGenerateEvent::getLootContext); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableUtils.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableUtils.java new file mode 100644 index 00000000000..de998f8c6c0 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/LootTableUtils.java @@ -0,0 +1,55 @@ +package org.skriptlang.skript.bukkit.loottables; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.loot.LootTable; +import org.bukkit.loot.Lootable; + +/** + * Utility class for loot tables. + */ +public class LootTableUtils { + + /** + * * Checks whether a block or entity is an instance of {@link Lootable}. This is done because a block is not an instance of Lootable, but a block state is. + * @param object the object to check. + * @return whether the object is lootable. + */ + public static boolean isLootable(Object object) { + if (object instanceof Block block) + object = block.getState(); + return object instanceof Lootable; + } + + /** + * Gets the Lootable instance of an object. You should call {@link #isLootable(Object)} before calling this method. + * @param object the object to get the Lootable instance of. + * @return the Lootable instance of the object. + */ + public static Lootable getAsLootable(Object object) { + if (object instanceof Block block) + object = block.getState(); + if (object instanceof Lootable lootable) + return lootable; + return null; + } + + /** + * Gets the loot table of an object. You should call {@link #isLootable(Object)} before calling this method. + * @param object the object to get the loot table of. + * @return returns the LootTable of the object. + */ + public static LootTable getLootTable(Object object) { + return getAsLootable(object).getLootTable(); + } + + /** + * Updates the state of a Lootable. This is done because setting the LootTable or seed of a BlockState changes the NBT value, but is never updated. + * @param lootable the Lootable to update the state of. + */ + public static void updateState(Lootable lootable) { + if (lootable instanceof BlockState blockState) + blockState.update(true, false); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondHasLootTable.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondHasLootTable.java new file mode 100644 index 00000000000..b02336fca21 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondHasLootTable.java @@ -0,0 +1,42 @@ +package org.skriptlang.skript.bukkit.loottables.elements.conditions; + +import ch.njol.skript.conditions.base.PropertyCondition; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import org.skriptlang.skript.bukkit.loottables.LootTableUtils; + +@Name("Has Loot Table") +@Description( + "Checks whether an entity or block has a loot table. " + + "The loot tables of chests will be deleted when the chest is opened or broken." +) +@Examples({ + "set event-block to chest", + "if event-block has a loot table:", + "\t# this will never happen, because it doesn't have a loot table.", + "", + "set loot table of event-block to \"minecraft:chests/simple_dungeon\"", + "", + "if event-block has a loot table:", + "\t# this will happen, because it now has a loot table." +}) +@Since("INSERT VERSION") +public class CondHasLootTable extends PropertyCondition { + + static { + register(CondHasLootTable.class, PropertyType.HAVE, "[a] loot[ ]table", "blocks/entities"); + } + + @Override + public boolean check(Object object) { + return LootTableUtils.isLootable(object) && LootTableUtils.getLootTable(object) != null; + } + + @Override + protected String getPropertyName() { + return "a loot table"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondIsLootable.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondIsLootable.java new file mode 100644 index 00000000000..9178fe16563 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/conditions/CondIsLootable.java @@ -0,0 +1,48 @@ +package org.skriptlang.skript.bukkit.loottables.elements.conditions; + +import ch.njol.skript.conditions.base.PropertyCondition; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import org.skriptlang.skript.bukkit.loottables.LootTableUtils; + +@Name("Is Lootable") +@Description( + "Checks whether an entity or block is lootable. " + + "Lootables are entities or blocks that can have a loot table." +) +@Examples({ + "spawn a pig at event-location", + "set {_pig} to last spawned entity", + "if {_pig} is lootable:", + "\tset loot table of {_pig} to \"minecraft:entities/cow\"", + "\t# the pig will now drop the loot of a cow when killed, because it is indeed a lootable entity.", + + "set block at event-location to chest", + "if block at event-location is lootable:", + "\tset loot table of block at event-location to \"minecraft:chests/simple_dungeon\"", + "\t# the chest will now generate the loot of a simple dungeon when opened, because it is indeed a lootable block.", + + "set block at event-location to wool block", + "if block at event-location is lootable:", + "\t# uh oh, nothing will happen because a wool is not a lootable block." +}) +@Since("INSERT VERSION") +public class CondIsLootable extends PropertyCondition { + + static { + register(CondIsLootable.class, "lootable", "blocks/entities"); + } + + @Override + public boolean check(Object object) { + return LootTableUtils.isLootable(object); + } + + @Override + protected String getPropertyName() { + return "lootable"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/effects/EffGenerateLoot.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/effects/EffGenerateLoot.java new file mode 100644 index 00000000000..ceab5b0928d --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/effects/EffGenerateLoot.java @@ -0,0 +1,93 @@ +package org.skriptlang.skript.bukkit.loottables.elements.effects; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.SyntaxStringBuilder; +import ch.njol.util.Kleenean; +import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.inventory.Inventory; +import org.bukkit.loot.LootContext; +import org.bukkit.loot.LootTable; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextWrapper; + +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +@Name("Generate Loot") +@Description({ + "Generates the loot in the specified inventories from a loot table using a loot context. " + + "Not specifying a loot context will use a loot context with a location at the world's origin.", + "Note that if the inventory is full, it will cause warnings in the console due to over-filling the inventory." +}) +@Examples({ + "generate loot of loot table \"minecraft:chests/simple_dungeon\" using loot context at player in {_inventory}", + "generate loot using \"minecraft:chests/shipwreck_supply\" in {_inventory}" +}) +@Since("INSERT VERSION") +public class EffGenerateLoot extends Effect { + + static { + Skript.registerEffect(EffGenerateLoot.class, + "generate [the] loot (of|using) %loottable% [(with|using) %-lootcontext%] in %inventories%" + ); + } + + private Expression lootTable; + private Expression context; + private Expression inventories; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + lootTable = (Expression) exprs[0]; + context = (Expression) exprs[1]; + inventories = (Expression) exprs[2]; + return true; + } + + @Override + protected void execute(Event event) { + Random random = ThreadLocalRandom.current(); + + LootContext context; + if (this.context != null) { + context = this.context.getSingle(event); + if (context == null) + return; + } else { + context = new LootContextWrapper(Bukkit.getWorlds().get(0).getSpawnLocation()).getContext(); + } + + LootTable table = lootTable.getSingle(event); + if (table == null) + return; + + for (Inventory inventory : inventories.getArray(event)) { + try { + // todo: perhaps runtime error in the future + table.fillInventory(inventory, random, context); + } catch (IllegalArgumentException ignore) {} + } + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); + + builder.append("generate loot using", lootTable); + if (context != null) + builder.append("with", context); + builder.append("in", inventories); + + return builder.toString(); + } + +} diff --git a/src/main/java/ch/njol/skript/expressions/ExprLoot.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLoot.java similarity index 50% rename from src/main/java/ch/njol/skript/expressions/ExprLoot.java rename to src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLoot.java index 0e301cea422..fe01cd2c1d4 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprLoot.java +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLoot.java @@ -1,22 +1,4 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ -package ch.njol.skript.expressions; +package org.skriptlang.skript.bukkit.loottables.elements.expressions; import ch.njol.skript.Skript; import ch.njol.skript.classes.Changer.ChangeMode; @@ -43,17 +25,16 @@ @Description("The loot that will be generated in a 'loot generate' event.") @Examples({ "on loot generate:", - "\tchance of %10", - "\tadd 64 diamonds", - "\tsend \"You hit the jackpot!!\"" + "\tchance of %10", + "\tadd 64 diamonds to loot", + "\tsend \"You hit the jackpot!!\"" }) @Since("2.7") @RequiredPlugins("MC 1.16+") public class ExprLoot extends SimpleExpression { static { - if (Skript.classExists("org.bukkit.event.world.LootGenerateEvent")) - Skript.registerExpression(ExprLoot.class, ItemStack.class, ExpressionType.SIMPLE, "[the] loot"); + Skript.registerExpression(ExprLoot.class, ItemStack.class, ExpressionType.SIMPLE, "[the] loot"); } @Override @@ -67,31 +48,25 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override @Nullable - protected ItemStack[] get(Event event) { - if (!(event instanceof LootGenerateEvent)) + protected ItemStack @Nullable [] get(Event event) { + if (!(event instanceof LootGenerateEvent lootEvent)) return new ItemStack[0]; - return ((LootGenerateEvent) event).getLoot().toArray(new ItemStack[0]); + return lootEvent.getLoot().toArray(new ItemStack[0]); } @Override @Nullable - public Class[] acceptChange(ChangeMode mode) { - switch (mode) { - case ADD: - case REMOVE: - case SET: - case DELETE: - return CollectionUtils.array(ItemStack[].class); - default: - return null; - } + public Class @Nullable [] acceptChange(ChangeMode mode) { + return switch (mode) { + case DELETE, ADD, REMOVE, SET -> CollectionUtils.array(ItemStack[].class); + default -> null; + }; } @Override - public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { - if (!(event instanceof LootGenerateEvent)) + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (!(event instanceof LootGenerateEvent lootEvent)) return; - LootGenerateEvent lootEvent = (LootGenerateEvent) event; List items = null; if (delta != null) { @@ -101,18 +76,10 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) { } switch (mode) { - case ADD: - lootEvent.getLoot().addAll(items); - break; - case REMOVE: - lootEvent.getLoot().removeAll(items); - break; - case SET: - lootEvent.setLoot(items); - break; - case DELETE: - lootEvent.getLoot().clear(); - break; + case ADD -> lootEvent.getLoot().addAll(items); + case REMOVE -> lootEvent.getLoot().removeAll(items); + case SET -> lootEvent.setLoot(items); + case DELETE -> lootEvent.getLoot().clear(); } } diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContext.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContext.java new file mode 100644 index 00000000000..599fe0ea419 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContext.java @@ -0,0 +1,32 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.EventValueExpression; +import org.bukkit.loot.LootContext; + +@Name("Loot Context") +@Description("The loot context involved in the context create section.") +@Examples({ + "set {_context} to a new loot context at {_location}:", + "\tbroadcast loot context" +}) +@Since("INSERT VERSION") +public class ExprLootContext extends EventValueExpression { + + static { + register(ExprLootContext.class, LootContext.class, "loot[ ]context"); + } + + public ExprLootContext() { + super(LootContext.class); + } + + @Override + public String toString() { + return "the loot context"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextEntity.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextEntity.java new file mode 100644 index 00000000000..45b16ccb8cc --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextEntity.java @@ -0,0 +1,71 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.Entity; +import org.bukkit.event.Event; +import org.bukkit.loot.LootContext; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextCreateEvent; + +@Name("Looted Entity of Loot Context") +@Description("Returns the looted entity of a loot context.") +@Examples({ + "set {_entity} to looted entity of {_context}", + "", + "set {_context} to a loot context at player:", + "\tset loot luck value to 10", + "\tset looter to player", + "\tset looted entity to last spawned pig" +}) +@Since("INSERT VERSION") +public class ExprLootContextEntity extends SimplePropertyExpression { + + static { + registerDefault(ExprLootContextEntity.class, Entity.class, "looted entity", "lootcontexts"); + } + + @Override + public @Nullable Entity convert(LootContext context) { + return context.getLootedEntity(); + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (!getParser().isCurrentEvent(LootContextCreateEvent.class)) { + Skript.error("You cannot set the looted entity of an existing loot context."); + return null; + } + + return switch (mode) { + case SET, DELETE, RESET -> CollectionUtils.array(Entity.class); + default -> null; + }; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (!(event instanceof LootContextCreateEvent createEvent)) + return; + + Entity entity = delta != null ? (Entity) delta[0] : null; + createEvent.getContextWrapper().setEntity(entity); + } + + @Override + public Class getReturnType() { + return Entity.class; + } + + @Override + protected String getPropertyName() { + return "looted entity"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLocation.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLocation.java new file mode 100644 index 00000000000..c6b9f344266 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLocation.java @@ -0,0 +1,69 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.Location; +import org.bukkit.event.Event; +import org.bukkit.loot.LootContext; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextCreateEvent; + +@Name("Loot Location of Loot Context") +@Description("Returns the loot location of a loot context.") +@Examples({ + "set {_player} to player", + "set {_context} to a loot context at player:", + "\tif {_player} is in \"world_nether\":", + "\t\tset loot location to location of last spawned pig", + "send loot location of {_context} to player" +}) +@Since("INSERT VERSION") +public class ExprLootContextLocation extends SimplePropertyExpression { + + static { + registerDefault(ExprLootContextLocation.class, Location.class, "loot[ing] [context] location", "lootcontexts"); + } + + @Override + public Location convert(LootContext context) { + return context.getLocation(); + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (!getParser().isCurrentEvent(LootContextCreateEvent.class)) { + Skript.error("You cannot set the loot context location of an existing loot context."); + return null; + } + + if (mode == ChangeMode.SET) + return CollectionUtils.array(Location.class); + return null; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (!(event instanceof LootContextCreateEvent createEvent)) + return; + + assert delta != null; + createEvent.getContextWrapper().setLocation((Location) delta[0]); + } + + @Override + public Class getReturnType() { + return Location.class; + } + + @Override + protected String getPropertyName() { + return "loot location"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLooter.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLooter.java new file mode 100644 index 00000000000..81ec1ac8fc9 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLooter.java @@ -0,0 +1,76 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.loot.LootContext; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextCreateEvent; + +@Name("Looter of Loot Context") +@Description( + "Returns the looter of a loot context. " + + "Note that setting the looter will read the looter's tool enchantments (e.g. looting) when generating loot." +) +@Examples({ + "set {_killer} to looter of {_context}", + "", + "set {_context} to a loot context at player:", + "\tset loot luck value to 10", + "\tset looter to player", + "\tset looted entity to last spawned pig" +}) +@Since("INSERT VERSION") +public class ExprLootContextLooter extends SimplePropertyExpression { + + static { + registerDefault(ExprLootContextLooter.class, Player.class, "(looter|looting player)", "lootcontexts"); + } + + @Override + public @Nullable Player convert(LootContext context) { + if (context.getKiller() instanceof Player player) + return player; + return null; + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (!getParser().isCurrentEvent(LootContextCreateEvent.class)) { + Skript.error("You cannot set the looting player of an existing loot context."); + return null; + } + + return switch (mode) { + case SET, DELETE, RESET -> CollectionUtils.array(Player.class); + default -> null; + }; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (!(event instanceof LootContextCreateEvent createEvent)) + return; + + Player player = delta != null ? (Player) delta[0] : null; + createEvent.getContextWrapper().setKiller(player); + } + + @Override + public Class getReturnType() { + return Player.class; + } + + @Override + protected String getPropertyName() { + return "looting player"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLuck.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLuck.java new file mode 100644 index 00000000000..b9120d66381 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootContextLuck.java @@ -0,0 +1,77 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.event.Event; +import org.bukkit.loot.LootContext; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextCreateEvent; +import org.skriptlang.skript.bukkit.loottables.LootContextWrapper; + +@Name("Luck of Loot Context") +@Description("Returns the luck of a loot context as a float. This represents the luck potion effect that an entity can have.") +@Examples({ + "set {_luck} to loot luck value of {_context}", + "", + "set {_context} to a loot context at player:", + "\tset loot luck value to 10", + "\tset looter to player", + "\tset looted entity to last spawned pig" +}) +@Since("INSERT VERSION") +public class ExprLootContextLuck extends SimplePropertyExpression { + + static { + registerDefault(ExprLootContextLuck.class, Float.class, "loot[ing] [context] luck [value|factor]", "lootcontexts"); + } + + @Override + public @Nullable Float convert(LootContext context) { + return context.getLuck(); + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (!getParser().isCurrentEvent(LootContextCreateEvent.class)) { + Skript.error("You cannot set the loot context luck of an existing loot context."); + return null; + } + + return switch (mode) { + case SET, DELETE, RESET, ADD, REMOVE -> CollectionUtils.array(Float.class); + default -> null; + }; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + if (!(event instanceof LootContextCreateEvent createEvent)) + return; + + LootContextWrapper wrapper = createEvent.getContextWrapper(); + float luck = delta != null ? (float) delta[0] : 0f; + + switch (mode) { + case SET, DELETE, RESET -> wrapper.setLuck(luck); + case ADD -> wrapper.setLuck(wrapper.getLuck() + luck); + case REMOVE -> wrapper.setLuck(wrapper.getLuck() - luck); + } + } + + @Override + public Class getReturnType() { + return Float.class; + } + + @Override + protected String getPropertyName() { + return "loot luck factor"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootItems.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootItems.java new file mode 100644 index 00000000000..b07a5c07691 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootItems.java @@ -0,0 +1,105 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.SyntaxStringBuilder; +import ch.njol.skript.lang.util.SimpleExpression; +import ch.njol.util.Kleenean; +import org.bukkit.Bukkit; +import org.bukkit.event.Event; +import org.bukkit.inventory.ItemStack; +import org.bukkit.loot.LootContext; +import org.bukkit.loot.LootTable; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextWrapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +@Name("Loot of Loot Table") +@Description( + "Returns the items of a loot table using a loot context. " + + "Not specifying a loot context will use a loot context with a location at the world's origin." +) +@Examples({ + "set {_items::*} to loot items of the loot table \"minecraft:chests/simple_dungeon\" with loot context {_context}", + "# this will set {_items::*} to the items that would be dropped from the simple dungeon loot table with the given loot context", + "", + "give player loot items of entity's loot table with loot context {_context}", + "# this will give the player the items that the entity would drop with the given loot context" +}) +@Since("INSERT VERSION") +public class ExprLootItems extends SimpleExpression { + + static { + Skript.registerExpression(ExprLootItems.class, ItemStack.class, ExpressionType.COMBINED, + "[the] loot of %loottables% [(with|using) %-lootcontext%]", + "%loottables%'[s] loot [(with|using) %-lootcontext%]" + ); + } + + private Expression lootTables; + private Expression context; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + lootTables = (Expression) exprs[0]; + context = (Expression) exprs[1]; + return true; + } + + @Override + protected ItemStack @Nullable [] get(Event event) { + LootContext context; + if (this.context != null) { + context = this.context.getSingle(event); + if (context == null) + return new ItemStack[0]; + } else { + context = new LootContextWrapper(Bukkit.getWorlds().get(0).getSpawnLocation()).getContext(); + } + + List items = new ArrayList<>(); + + Random random = ThreadLocalRandom.current(); + for (LootTable lootTable : lootTables.getArray(event)) { + try { + // todo: perhaps runtime error in the future + items.addAll(lootTable.populateLoot(random, context)); + } catch (IllegalArgumentException ignore) {} + } + + return items.toArray(new ItemStack[0]); + } + + @Override + public boolean isSingle() { + return false; + } + + @Override + public Class getReturnType() { + return ItemStack.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); + + builder.append("the loot of", lootTables); + if (context != null) + builder.append("with", context); + + return builder.toString(); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTable.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTable.java new file mode 100644 index 00000000000..fe745a0feda --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTable.java @@ -0,0 +1,77 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.event.Event; +import org.bukkit.loot.LootTable; +import org.bukkit.loot.Lootable; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootTableUtils; + +@Name("Loot Table") +@Description({ + "Returns the loot table of an entity or block.", + "Setting the loot table of a block will update the block state, and once opened will " + + "generate loot of the specified loot table. Please note that doing so may cause " + + "warnings in the console due to over-filling the chest.", + "Please note that resetting/deleting the loot table of an ENTITY will reset the entity's loot table to its default.", +}) +@Examples({ + "set loot table of event-entity to \"minecraft:entities/ghast\"", + "# this will set the loot table of the entity to a ghast's loot table, thus dropping ghast tears and gunpowder", + "", + "set loot table of event-block to \"minecraft:chests/simple_dungeon\"", +}) +@Since("INSERT VERSION") +public class ExprLootTable extends SimplePropertyExpression { + + static { + register(ExprLootTable.class, LootTable.class, "loot[ ]table[s]", "entities/blocks"); + } + + @Override + public @Nullable LootTable convert(Object object) { + if (LootTableUtils.isLootable(object)) + return LootTableUtils.getLootTable(object); + return null; + } + + @Override + public Class @Nullable [] acceptChange(ChangeMode mode) { + return switch (mode) { + case SET, DELETE, RESET -> CollectionUtils.array(LootTable.class); + default -> null; + }; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + LootTable lootTable = delta != null ? ((LootTable) delta[0]) : null; + + for (Object object : getExpr().getArray(event)) { + if (!LootTableUtils.isLootable(object)) + continue; + + Lootable lootable = LootTableUtils.getAsLootable(object); + + lootable.setLootTable(lootTable); + LootTableUtils.updateState(lootable); + } + } + + @Override + public Class getReturnType() { + return LootTable.class; + } + + @Override + protected String getPropertyName() { + return "loot table"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTableFromString.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTableFromString.java new file mode 100644 index 00000000000..d0e0781497c --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTableFromString.java @@ -0,0 +1,74 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser; +import ch.njol.skript.lang.util.SimpleExpression; +import ch.njol.util.Kleenean; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.event.Event; +import org.bukkit.loot.LootTable; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +@Name("Loot Table from Key") +@Description("Returns the loot table from a namespaced key.") +@Examples("set {_table} to loot table \"minecraft:chests/simple_dungeon\"") +@Since("INSERT VERSION") +public class ExprLootTableFromString extends SimpleExpression { + + static { + Skript.registerExpression(ExprLootTableFromString.class, LootTable.class, ExpressionType.COMBINED, + "[the] loot[ ]table[s] %strings%" + ); + } + + private Expression keys; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + //noinspection unchecked + keys = (Expression) exprs[0]; + return true; + } + + @Override + protected LootTable @Nullable [] get(Event event) { + List lootTables = new ArrayList<>(); + for (String key : keys.getArray(event)) { + NamespacedKey namespacedKey = NamespacedKey.fromString(key); + if (namespacedKey == null) + continue; + + LootTable lootTable = Bukkit.getLootTable(namespacedKey); + if (lootTable != null) + lootTables.add(lootTable); + } + + return lootTables.toArray(new LootTable[0]); + } + + @Override + public boolean isSingle() { + return keys.isSingle(); + } + + @Override + public Class getReturnType() { + return LootTable.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "the loot table of " + keys.toString(event, debug); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTableSeed.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTableSeed.java new file mode 100644 index 00000000000..e73d2f72cb8 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprLootTableSeed.java @@ -0,0 +1,65 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.classes.Changer.ChangeMode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SimplePropertyExpression; +import ch.njol.util.coll.CollectionUtils; +import org.bukkit.event.Event; +import org.bukkit.loot.Lootable; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootTableUtils; + +@Name("Seed of Loot Table") +@Description("Returns the seed of a loot table. Setting the seed of a block or entity that does not have a loot table will not do anything.") +@Examples({ + "set {_seed} loot table seed of block", + "set loot table seed of entity to 123456789" +}) +@Since("INSERT VERSION") +public class ExprLootTableSeed extends SimplePropertyExpression { + + static { + register(ExprLootTableSeed.class, Long.class, "loot[[ ]table] seed[s]", "entities/blocks"); + } + + @Override + public @Nullable Long convert(Object object) { + Lootable lootable = LootTableUtils.getAsLootable(object); + return lootable != null ? lootable.getSeed() : null; + } + + public Class @Nullable [] acceptChange(ChangeMode mode) { + if (mode == ChangeMode.SET) + return CollectionUtils.array(Number.class); + return null; + } + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + assert delta != null; + long seedValue = ((Number) delta[0]).longValue(); + + for (Object object : getExpr().getArray(event)) { + if (!LootTableUtils.isLootable(object)) + continue; + + Lootable lootable = LootTableUtils.getAsLootable(object); + lootable.setSeed(seedValue); + LootTableUtils.updateState(lootable); + } + } + + @Override + public Class getReturnType() { + return Long.class; + } + + @Override + protected String getPropertyName() { + return "loot table seed"; + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprSecCreateLootContext.java b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprSecCreateLootContext.java new file mode 100644 index 00000000000..2dfea4abc8f --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/loottables/elements/expressions/ExprSecCreateLootContext.java @@ -0,0 +1,96 @@ +package org.skriptlang.skript.bukkit.loottables.elements.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.config.SectionNode; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.SectionExpression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.*; +import ch.njol.skript.registrations.EventValues; +import ch.njol.skript.util.Direction; +import ch.njol.skript.variables.Variables; +import ch.njol.util.Kleenean; +import org.bukkit.Location; +import org.bukkit.event.Event; +import org.bukkit.loot.LootContext; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.loottables.LootContextCreateEvent; +import org.skriptlang.skript.bukkit.loottables.LootContextWrapper; + +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +@Name("Create Loot Context") +@Description("Create a loot context.") +@Examples({ + "set {_player} to player", + "set {_context} to a loot context at player:", + "\tset loot luck value to 10", + "\tset looter to {_player}", + "\tset looted entity to last spawned pig", + "give player loot items of loot table \"minecraft:entities/iron_golem\" with loot context {_context}" +}) +@Since("INSERT VERSION") +public class ExprSecCreateLootContext extends SectionExpression { + + static { + Skript.registerExpression(ExprSecCreateLootContext.class, LootContext.class, ExpressionType.COMBINED, + "[a] loot context %direction% %location%"); + EventValues.registerEventValue(LootContextCreateEvent.class, LootContext.class, event -> event.getContextWrapper().getContext()); + } + + private Trigger trigger; + private Expression location; + + @Override + public boolean init(Expression[] exprs, int pattern, Kleenean isDelayed, ParseResult result, @Nullable SectionNode node, @Nullable List triggerItems) { + if (node != null) { + AtomicBoolean delayed = new AtomicBoolean(false); + Runnable afterLoading = () -> delayed.set(!getParser().getHasDelayBefore().isFalse()); + //noinspection unchecked + trigger = loadCode(node, "create loot context", afterLoading, LootContextCreateEvent.class); + if (delayed.get()) { + Skript.error("Delays cannot be used within a 'create loot context' section."); + return false; + } + } + //noinspection unchecked + location = Direction.combine((Expression) exprs[0], (Expression) exprs[1]); + return true; + } + + @Override + protected LootContext @Nullable [] get(Event event) { + Location loc = location.getSingle(event); + if (loc == null) + return new LootContext[0]; + + LootContextWrapper wrapper = new LootContextWrapper(loc); + if (trigger != null) { + LootContextCreateEvent contextEvent = new LootContextCreateEvent(wrapper); + Variables.withLocalVariables(event, contextEvent, () -> + TriggerItem.walk(trigger, contextEvent) + ); + } + return new LootContext[]{wrapper.getContext()}; + } + + @Override + public boolean isSingle() { + return true; + } + + @Override + public Class getReturnType() { + return LootContext.class; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "a loot context " + location.toString(event, debug); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/misc/rotation/package-info.java b/src/main/java/org/skriptlang/skript/bukkit/misc/rotation/package-info.java index e727d083aa8..ddd2cbbcf13 100644 --- a/src/main/java/org/skriptlang/skript/bukkit/misc/rotation/package-info.java +++ b/src/main/java/org/skriptlang/skript/bukkit/misc/rotation/package-info.java @@ -1 +1,19 @@ +/** + * This file is part of Skript. + * + * Skript is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Skript is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Skript. If not, see . + * + * Copyright Peter Güttinger, SkriptLang team and contributors + */ package org.skriptlang.skript.bukkit.misc.rotation; diff --git a/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitRegistryKeys.java b/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitRegistryKeys.java new file mode 100644 index 00000000000..336b84a2361 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitRegistryKeys.java @@ -0,0 +1,22 @@ +package org.skriptlang.skript.bukkit.registration; + +import ch.njol.skript.lang.SkriptEvent; +import org.jetbrains.annotations.ApiStatus; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos.Event; +import org.skriptlang.skript.registration.SyntaxRegistry; +import org.skriptlang.skript.registration.SyntaxRegistry.Key; + +/** + * A class containing {@link SyntaxRegistry} keys for Bukkit-specific syntax elements. + */ +@ApiStatus.Experimental +public final class BukkitRegistryKeys { + + private BukkitRegistryKeys() { } + + /** + * A key representing the Bukkit-specific {@link SkriptEvent} syntax element. + */ + public static final Key> EVENT = Key.of("event"); + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitSyntaxInfos.java b/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitSyntaxInfos.java new file mode 100644 index 00000000000..f46881c2d37 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitSyntaxInfos.java @@ -0,0 +1,353 @@ +package org.skriptlang.skript.bukkit.registration; + +import ch.njol.skript.lang.SkriptEvent; +import ch.njol.skript.lang.SkriptEvent.ListeningBehavior; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfosImpl.EventImpl; +import org.skriptlang.skript.registration.SyntaxInfo; + +import java.util.Collection; + +/** + * A class containing the interfaces representing Bukkit-specific SyntaxInfo implementations. + */ +@ApiStatus.Experimental +public final class BukkitSyntaxInfos { + + private BukkitSyntaxInfos() { } + + /** + * A syntax info to be used for {@link SkriptEvent}s. + * It contains additional details including the Bukkit events represented along with documentation data. + * @param The class providing the implementation of the SkriptEvent this info represents. + */ + public interface Event extends SyntaxInfo { + + /** + * @param eventClass The Structure class the info will represent. + * @param name The name of the SkriptEvent. + * @return A Structure-specific builder for creating a syntax info representing type. + */ + static Builder, E> builder( + Class eventClass, String name + ) { + return new EventImpl.BuilderImpl<>(eventClass, name); + } + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Builder, E> builder(); + + /** + * @return The listening behavior for the SkriptEvent. Determines when the event should trigger. + */ + ListeningBehavior listeningBehavior(); + + /** + * @return The name of the {@link SkriptEvent}. + */ + String name(); + + /** + * @return A documentation-friendly version of {@link #name()}. + */ + String id(); + + /** + * @return Documentation data. Represents the version of the plugin in which a syntax was added. + * @see ch.njol.skript.doc.Since + */ + @Nullable String since(); + + /** + * @return Documentation data. Used for identifying specific syntaxes in documentation. + * @see ch.njol.skript.doc.DocumentationId + */ + @Nullable String documentationId(); + + /** + * @return Documentation data. A description of a syntax. + * @see ch.njol.skript.doc.Description + */ + Collection description(); + + /** + * @return Documentation data. Examples for using a syntax. + * @see ch.njol.skript.doc.Examples + */ + Collection examples(); + + /** + * @return Documentation data. Keywords are used by the search engine to provide relevant results. + * @see ch.njol.skript.doc.Keywords + */ + Collection keywords(); + + /** + * @return Documentation data. Plugins other than Skript that are required by a syntax. + * @see ch.njol.skript.doc.RequiredPlugins + */ + Collection requiredPlugins(); + + /** + * @return A collection of the classes representing the Bukkit events the {@link SkriptEvent} listens for. + */ + Collection> events(); + + /** + * An Event-specific builder is used for constructing a new Event syntax info. + * @see #builder(Class, String) + * @param The type of builder being used. + * @param The SkriptEvent class providing the implementation of the syntax info being built. + */ + interface Builder, E extends SkriptEvent> extends SyntaxInfo.Builder { + + /** + * Sets the listening behavior the event will use. + * This determines when the event should trigger. + * By default, this is {@link ListeningBehavior#UNCANCELLED}. + * @param listeningBehavior The listening behavior to use. + * @return This builder. + * @see Event#listeningBehavior() + */ + @Contract("_ -> this") + B listeningBehavior(ListeningBehavior listeningBehavior); + + /** + * Sets the "since" value the event's documentation will use. + * @param since The "since" value to use. + * @return This builder. + * @see Event#since() + */ + @Contract("_ -> this") + B since(String since); + + /** + * Sets the documentation identifier the event's documentation will use. + * @param documentationId The documentation identifier to use. + * @return This builder. + * @see Event#documentationId() + */ + @Contract("_ -> this") + B documentationId(String documentationId); + + /** + * Adds a description line to the event's documentation. + * @param description The description line to add. + * @return This builder. + * @see Event#description() + */ + @Contract("_ -> this") + B addDescription(String description); + + /** + * Adds lines of description to the event's documentation. + * @param description The description lines to add. + * @return This builder. + * @see Event#description() + */ + @Contract("_ -> this") + B addDescription(String... description); + + /** + * Adds lines of description to the event's documentation. + * @param description The description lines to add. + * @return This builder. + * @see Event#description() + */ + @Contract("_ -> this") + B addDescription(Collection description); + + /** + * Removes all description lines from the event's documentation. + * @return This builder. + * @see Event#description() + */ + @Contract("-> this") + B clearDescription(); + + /** + * Adds an example to the event's documentation. + * @param example The example to add. + * @return This builder. + * @see Event#examples() + */ + @Contract("_ -> this") + B addExample(String example); + + /** + * Adds examples to the event's documentation. + * @param examples The examples to add. + * @return This builder. + * @see Event#examples() + */ + @Contract("_ -> this") + B addExamples(String... examples); + + /** + * Adds examples to the event's documentation. + * @param examples The examples to add. + * @return This builder. + * @see Event#examples() + */ + @Contract("_ -> this") + B addExamples(Collection examples); + + /** + * Removes all examples from the event's documentation. + * @return This builder. + * @see Event#examples() + */ + @Contract("-> this") + B clearExamples(); + + /** + * Adds a keyword to the event's documentation. + * @param keyword The keyword to add. + * @return This builder. + * @see Event#keywords() + */ + @Contract("_ -> this") + B addKeyword(String keyword); + + /** + * Adds keywords to the event's documentation. + * @param keywords The keywords to add. + * @return This builder. + * @see Event#keywords() + */ + @Contract("_ -> this") + B addKeywords(String... keywords); + + /** + * Adds keywords to the event's documentation. + * @param keywords The keywords to add. + * @return This builder. + * @see Event#keywords() + */ + @Contract("_ -> this") + B addKeywords(Collection keywords); + + /** + * Removes all keywords from the event's documentation. + * @return This builder. + * @see Event#keywords() + */ + @Contract("-> this") + B clearKeywords(); + + /** + * Adds a required plugin to event's documentation. + * @param plugin The required plugin to add. + * @return This builder. + * @see Event#requiredPlugins() + */ + @Contract("_ -> this") + B addRequiredPlugin(String plugin); + + /** + * Adds required plugins to the event's documentation. + * @param plugins The required plugins to add. + * @return This builder. + * @see Event#requiredPlugins() + */ + @Contract("_ -> this") + B addRequiredPlugins(String... plugins); + + /** + * Adds required plugins to the event's documentation. + * @param plugins The required plugins to add. + * @return This builder. + * @see Event#requiredPlugins() + */ + @Contract("_ -> this") + B addRequiredPlugins(Collection plugins); + + /** + * Removes all required plugins from the event's documentation. + * @return This builder. + * @see Event#requiredPlugins() + */ + B clearRequiredPlugins(); + + /** + * Adds an event to the event's documentation. + * @param event The event to add. + * @return This builder. + * @see Event#events() + */ + @Contract("_ -> this") + B addEvent(Class event); + + /** + * Adds events to the event's documentation. + * @param events The events to add. + * @return This builder. + * @see Event#events() + */ + @Contract("_ -> this") + B addEvents(Class... events); + + /** + * Adds events to the event's documentation. + * @param events The events to add. + * @return This builder. + * @see Event#events() + */ + @Contract("_ -> this") + B addEvents(Collection> events); + + /** + * Removes all events from the event's documentation. + * @return This builder. + * @see Event#events() + */ + @Contract("-> this") + B clearEvents(); + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Event build(); + + } + + } + + /** + * Fixes patterns in event by modifying every {@link ch.njol.skript.patterns.TypePatternElement} to be nullable. + */ + public static String fixPattern(String pattern) { + char[] chars = pattern.toCharArray(); + StringBuilder stringBuilder = new StringBuilder(); + + boolean inType = false; + for (int i = 0; i < chars.length; i++) { + char character = chars[i]; + stringBuilder.append(character); + + if (character == '%') { + // toggle inType + inType = !inType; + + // add the dash character if it's not already present + // a type specification can have two prefix characters for modification + if (inType && i + 2 < chars.length && chars[i + 1] != '-' && chars[i + 2] != '-') + stringBuilder.append('-'); + } else if (character == '\\' && i + 1 < chars.length) { + // Make sure we don't toggle inType for escape percentage signs + stringBuilder.append(chars[i + 1]); + i++; + } + } + return stringBuilder.toString(); + } + +} diff --git a/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitSyntaxInfosImpl.java b/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitSyntaxInfosImpl.java new file mode 100644 index 00000000000..c9b2105aedf --- /dev/null +++ b/src/main/java/org/skriptlang/skript/bukkit/registration/BukkitSyntaxInfosImpl.java @@ -0,0 +1,419 @@ +package org.skriptlang.skript.bukkit.registration; + +import ch.njol.skript.lang.SkriptEvent; +import ch.njol.skript.lang.SkriptEvent.ListeningBehavior; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos.Event; +import org.skriptlang.skript.registration.SyntaxInfo; +import org.skriptlang.skript.registration.SyntaxOrigin; +import org.skriptlang.skript.util.Priority; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Supplier; + +final class BukkitSyntaxInfosImpl { + + static final class EventImpl implements Event { + + private final SyntaxInfo defaultInfo; + private final ListeningBehavior listeningBehavior; + private final String name; + private final String id; + private final @Nullable String since; + private final @Nullable String documentationId; + private final Collection description; + private final Collection examples; + private final Collection keywords; + private final Collection requiredPlugins; + private final Collection> events; + + EventImpl( + SyntaxInfo defaultInfo, ListeningBehavior listeningBehavior, String name, + @Nullable String since, @Nullable String documentationId, Collection description, Collection examples, + Collection keywords, Collection requiredPlugins, Collection> events + ) { + this.defaultInfo = defaultInfo; + this.listeningBehavior = listeningBehavior; + this.name = name.startsWith("*") ? name.substring(1) : "On " + name; + this.id = name.toLowerCase(Locale.ENGLISH) + .replaceAll("[#'\"<>/&]", "") + .replaceAll("\\s+", "_"); + this.since = since; + this.documentationId = documentationId; + this.description = ImmutableList.copyOf(description); + this.examples = ImmutableList.copyOf(examples); + this.keywords = ImmutableList.copyOf(keywords); + this.requiredPlugins = ImmutableList.copyOf(requiredPlugins); + this.events = ImmutableList.copyOf(events); + } + + @Override + public Builder, E> builder() { + var builder = new BuilderImpl<>(type(), name); + defaultInfo.builder().applyTo(builder); + builder.listeningBehavior(listeningBehavior); + builder.documentationId(id); + if (since != null) { + builder.since(since); + } + if (documentationId != null) { + builder.documentationId(documentationId); + } + builder.addDescription(description); + builder.addExamples(examples); + builder.addKeywords(keywords); + builder.addRequiredPlugins(requiredPlugins); + builder.addEvents(events); + return builder; + } + + @Override + public ListeningBehavior listeningBehavior() { + return listeningBehavior; + } + + @Override + public String name() { + return name; + } + + @Override + public String id() { + return id; + } + + @Override + @Nullable + public String since() { + return since; + } + + @Override + @Nullable + public String documentationId() { + return documentationId; + } + + @Override + public Collection description() { + return description; + } + + @Override + public Collection examples() { + return examples; + } + + @Override + public Collection keywords() { + return keywords; + } + + @Override + public Collection requiredPlugins() { + return requiredPlugins; + } + + @Override + public Collection> events() { + return events; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + return (other instanceof Event event) && + Objects.equals(defaultInfo, other) && + Objects.equals(name(), event.name()) && + Objects.equals(events(), event.events()); + } + + @Override + public int hashCode() { + return Objects.hash(defaultInfo, name(), events()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("origin", origin()) + .add("type", type()) + .add("patterns", patterns()) + .add("priority", priority()) + .add("name", name()) + .add("events", events()) + .toString(); + } + + // + // default methods + // + + @Override + public SyntaxOrigin origin() { + return defaultInfo.origin(); + } + + @Override + public Class type() { + return defaultInfo.type(); + } + + @Override + public E instance() { + return defaultInfo.instance(); + } + + @Override + @Unmodifiable + public Collection patterns() { + return defaultInfo.patterns(); + } + + @Override + public Priority priority() { + return defaultInfo.priority(); + } + + @SuppressWarnings("unchecked") + static final class BuilderImpl, E extends SkriptEvent> implements Event.Builder { + + private final SyntaxInfo.Builder defaultBuilder; + private ListeningBehavior listeningBehavior = ListeningBehavior.UNCANCELLED; + private final String name; + private @Nullable String since; + private @Nullable String documentationId; + private final List description = new ArrayList<>(); + private final List examples = new ArrayList<>(); + private final List keywords = new ArrayList<>(); + private final List requiredPlugins = new ArrayList<>(); + private final List> events = new ArrayList<>(); + + BuilderImpl(Class type, String name) { + this.defaultBuilder = SyntaxInfo.builder(type); + this.name = name; + } + + @Override + public B listeningBehavior(ListeningBehavior listeningBehavior) { + this.listeningBehavior = listeningBehavior; + return (B) this; + } + + @Override + public B since(String since) { + this.since = since; + return (B) this; + } + + @Override + public B documentationId(String documentationId) { + this.documentationId = documentationId; + return (B) this; + } + + @Override + public B addDescription(String description) { + this.description.add(description); + return (B) this; + } + + @Override + public B addDescription(String... description) { + Collections.addAll(this.description, description); + return (B) this; + } + + @Override + public B addDescription(Collection description) { + this.description.addAll(description); + return (B) this; + } + + @Override + public B clearDescription() { + this.description.clear(); + return (B) this; + } + + @Override + public B addExample(String example) { + this.examples.add(example); + return (B) this; + } + + @Override + public B addExamples(String... examples) { + Collections.addAll(this.examples, examples); + return (B) this; + } + + @Override + public B addExamples(Collection examples) { + this.examples.addAll(examples); + return (B) this; + } + + @Override + public B clearExamples() { + this.examples.clear(); + return (B) this; + } + + @Override + public B addKeyword(String keyword) { + this.keywords.add(keyword); + return (B) this; + } + + @Override + public B addKeywords(String... keywords) { + Collections.addAll(this.keywords, keywords); + return (B) this; + } + + @Override + public B addKeywords(Collection keywords) { + this.keywords.addAll(keywords); + return (B) this; + } + + @Override + public B clearKeywords() { + this.keywords.clear(); + return (B) this; + } + + @Override + public B addRequiredPlugin(String plugin) { + this.requiredPlugins.add(plugin); + return (B) this; + } + + @Override + public B addRequiredPlugins(String... plugins) { + Collections.addAll(this.requiredPlugins, plugins); + return (B) this; + } + + @Override + public B addRequiredPlugins(Collection plugins) { + this.requiredPlugins.addAll(plugins); + return (B) this; + } + + @Override + public B clearRequiredPlugins() { + this.requiredPlugins.clear(); + return (B) this; + } + + @Override + public B addEvent(Class event) { + this.events.add(event); + return (B) this; + } + + @Override + public B addEvents(Class... events) { + Collections.addAll(this.events, events); + return (B) this; + } + + @Override + public B addEvents(Collection> events) { + this.events.addAll(events); + return (B) this; + } + + @Override + public B clearEvents() { + this.events.clear(); + return (B) this; + } + + @Override + public B origin(SyntaxOrigin origin) { + defaultBuilder.origin(origin); + return (B) this; + } + + @Override + public B supplier(Supplier supplier) { + defaultBuilder.supplier(supplier); + return (B) this; + } + + @Override + public B addPattern(String pattern) { + defaultBuilder.addPattern(pattern); + return (B) this; + } + + @Override + public B addPatterns(String... patterns) { + defaultBuilder.addPatterns(patterns); + return (B) this; + } + + @Override + public B addPatterns(Collection patterns) { + defaultBuilder.addPatterns(patterns); + return (B) this; + } + + @Override + public B clearPatterns() { + defaultBuilder.clearPatterns(); + return (B) this; + } + + @Override + public B priority(Priority priority) { + defaultBuilder.priority(priority); + return (B) this; + } + + @Override + public Event build() { + return new EventImpl<>( + defaultBuilder.build(), listeningBehavior, name, + since, documentationId, description, examples, keywords, requiredPlugins, events + ); + } + + @Override + public void applyTo(SyntaxInfo.Builder builder) { + defaultBuilder.applyTo(builder); + //noinspection rawtypes - Should be safe, generics will not influence this + if (builder instanceof Event.Builder eventBuilder) { + eventBuilder.listeningBehavior(listeningBehavior); + if (since != null) { + eventBuilder.since(since); + } + if (documentationId != null) { + eventBuilder.documentationId(documentationId); + } + eventBuilder.addDescription(description); + eventBuilder.addExamples(examples); + eventBuilder.addKeywords(keywords); + eventBuilder.addRequiredPlugins(requiredPlugins); + eventBuilder.addEvents(events); + } + } + + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java b/src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java index 10563db0b68..a30cd499133 100644 --- a/src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java +++ b/src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.arithmetic; import ch.njol.skript.Skript; diff --git a/src/main/java/org/skriptlang/skript/lang/arithmetic/DifferenceInfo.java b/src/main/java/org/skriptlang/skript/lang/arithmetic/DifferenceInfo.java index eb3a4bd485b..c41bc5e7a57 100644 --- a/src/main/java/org/skriptlang/skript/lang/arithmetic/DifferenceInfo.java +++ b/src/main/java/org/skriptlang/skript/lang/arithmetic/DifferenceInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.arithmetic; /** diff --git a/src/main/java/org/skriptlang/skript/lang/arithmetic/Operation.java b/src/main/java/org/skriptlang/skript/lang/arithmetic/Operation.java index 469be7dd08a..46574b07d58 100644 --- a/src/main/java/org/skriptlang/skript/lang/arithmetic/Operation.java +++ b/src/main/java/org/skriptlang/skript/lang/arithmetic/Operation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.arithmetic; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/org/skriptlang/skript/lang/arithmetic/OperationInfo.java b/src/main/java/org/skriptlang/skript/lang/arithmetic/OperationInfo.java index 6ad628fd040..c906a9ee3be 100644 --- a/src/main/java/org/skriptlang/skript/lang/arithmetic/OperationInfo.java +++ b/src/main/java/org/skriptlang/skript/lang/arithmetic/OperationInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.arithmetic; import com.google.common.base.MoreObjects; diff --git a/src/main/java/org/skriptlang/skript/lang/arithmetic/Operator.java b/src/main/java/org/skriptlang/skript/lang/arithmetic/Operator.java index 4c93807204c..ef15649e51d 100644 --- a/src/main/java/org/skriptlang/skript/lang/arithmetic/Operator.java +++ b/src/main/java/org/skriptlang/skript/lang/arithmetic/Operator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.arithmetic; import ch.njol.skript.Skript; diff --git a/src/main/java/org/skriptlang/skript/lang/comparator/Comparator.java b/src/main/java/org/skriptlang/skript/lang/comparator/Comparator.java index d06f508a735..53fb3c75102 100644 --- a/src/main/java/org/skriptlang/skript/lang/comparator/Comparator.java +++ b/src/main/java/org/skriptlang/skript/lang/comparator/Comparator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.comparator; /** diff --git a/src/main/java/org/skriptlang/skript/lang/comparator/ComparatorInfo.java b/src/main/java/org/skriptlang/skript/lang/comparator/ComparatorInfo.java index 261f499a494..5c4971febf9 100644 --- a/src/main/java/org/skriptlang/skript/lang/comparator/ComparatorInfo.java +++ b/src/main/java/org/skriptlang/skript/lang/comparator/ComparatorInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.comparator; /** diff --git a/src/main/java/org/skriptlang/skript/lang/comparator/Comparators.java b/src/main/java/org/skriptlang/skript/lang/comparator/Comparators.java index 1fc656c7377..43e8c2703c2 100644 --- a/src/main/java/org/skriptlang/skript/lang/comparator/Comparators.java +++ b/src/main/java/org/skriptlang/skript/lang/comparator/Comparators.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.comparator; import ch.njol.skript.Skript; diff --git a/src/main/java/org/skriptlang/skript/lang/comparator/ConvertedComparator.java b/src/main/java/org/skriptlang/skript/lang/comparator/ConvertedComparator.java index f8ba918e49e..63f181c9296 100644 --- a/src/main/java/org/skriptlang/skript/lang/comparator/ConvertedComparator.java +++ b/src/main/java/org/skriptlang/skript/lang/comparator/ConvertedComparator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.comparator; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/org/skriptlang/skript/lang/comparator/InverseComparator.java b/src/main/java/org/skriptlang/skript/lang/comparator/InverseComparator.java index 4207020ef65..737a4a481ca 100644 --- a/src/main/java/org/skriptlang/skript/lang/comparator/InverseComparator.java +++ b/src/main/java/org/skriptlang/skript/lang/comparator/InverseComparator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.comparator; /** diff --git a/src/main/java/org/skriptlang/skript/lang/comparator/Relation.java b/src/main/java/org/skriptlang/skript/lang/comparator/Relation.java index 1f52ed46106..912333256da 100644 --- a/src/main/java/org/skriptlang/skript/lang/comparator/Relation.java +++ b/src/main/java/org/skriptlang/skript/lang/comparator/Relation.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.comparator; /** diff --git a/src/main/java/org/skriptlang/skript/lang/converter/ChainedConverter.java b/src/main/java/org/skriptlang/skript/lang/converter/ChainedConverter.java index 1416e3be0cf..9741c426367 100644 --- a/src/main/java/org/skriptlang/skript/lang/converter/ChainedConverter.java +++ b/src/main/java/org/skriptlang/skript/lang/converter/ChainedConverter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.converter; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/org/skriptlang/skript/lang/converter/Converter.java b/src/main/java/org/skriptlang/skript/lang/converter/Converter.java index 68762d90cd5..6c7df376f45 100644 --- a/src/main/java/org/skriptlang/skript/lang/converter/Converter.java +++ b/src/main/java/org/skriptlang/skript/lang/converter/Converter.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.converter; import org.jetbrains.annotations.Nullable; @@ -37,15 +19,36 @@ public interface Converter { /** * A Converter flag declaring this Converter cannot be chained to another Converter. * This means that this Converter must be the beginning of a chain. + *
+ * Note: unchecked casts are not permitted before this converter + * (e.g. {@code Object} to {@param }). */ int NO_LEFT_CHAINING = 1; /** * A Converter flag declaring that another Converter cannot be chained to this Converter. * This means that this Converter must be the end of a chain. + *
+ * Note: unchecked casts are not permitted after this converter + * (e.g. {@param } to {@param }). */ int NO_RIGHT_CHAINING = 2; + /** + * A Converter flag declaring that the input/output of this can use an unchecked cast, + * when combined with {@link #NO_LEFT_CHAINING} or {@link #NO_RIGHT_CHAINING}. + *
+ * An unchecked cast would be {@code Number -> Integer}. (Not all numbers are integers, some are floats!) + *
+ *
+ * When combined with {@link #NO_RIGHT_CHAINING} the output can be conformed with an unchecked cast, + * e.g. {@code String -> Number (-> cast Integer)}. + *
+ * When combined with {@link #NO_RIGHT_CHAINING} the output can be conformed with an unchecked cast, + * e.g. {@code (cast Object ->) Integer -> String}. + */ + int ALLOW_UNSAFE_CASTS = 4; + /** * A Converter flag declaring that this Converter cannot be a part of a chain. */ diff --git a/src/main/java/org/skriptlang/skript/lang/converter/ConverterInfo.java b/src/main/java/org/skriptlang/skript/lang/converter/ConverterInfo.java index 1b00d7041a3..55f112e4c42 100644 --- a/src/main/java/org/skriptlang/skript/lang/converter/ConverterInfo.java +++ b/src/main/java/org/skriptlang/skript/lang/converter/ConverterInfo.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.converter; /** diff --git a/src/main/java/org/skriptlang/skript/lang/converter/Converters.java b/src/main/java/org/skriptlang/skript/lang/converter/Converters.java index 0daeadfc714..1efeb559676 100644 --- a/src/main/java/org/skriptlang/skript/lang/converter/Converters.java +++ b/src/main/java/org/skriptlang/skript/lang/converter/Converters.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.converter; import ch.njol.skript.Skript; @@ -304,8 +286,13 @@ private static Converte // Attempt to find converters that have either 'from' OR 'to' not exactly matching for (ConverterInfo unknownInfo : CONVERTERS) { + int flags = unknownInfo.getFlags(); if (unknownInfo.getFrom().isAssignableFrom(fromType) && unknownInfo.getTo().isAssignableFrom(toType)) { ConverterInfo info = (ConverterInfo) unknownInfo; + if ((flags & Converter.ALLOW_UNSAFE_CASTS) == 0) { + if ((flags & Converter.NO_RIGHT_CHAINING) == Converter.NO_RIGHT_CHAINING) + continue; + } // 'to' doesn't exactly match and needs to be filtered // Basically, this converter might convert 'F' into something that's shares a parent with 'T' @@ -319,6 +306,10 @@ private static Converte } else if (fromType.isAssignableFrom(unknownInfo.getFrom()) && toType.isAssignableFrom(unknownInfo.getTo())) { ConverterInfo info = (ConverterInfo) unknownInfo; + if ((flags & Converter.ALLOW_UNSAFE_CASTS) == 0) { + if ((flags & Converter.NO_LEFT_CHAINING) == Converter.NO_LEFT_CHAINING) + continue; + } // 'from' doesn't exactly match and needs to be filtered // Basically, this converter will only convert certain 'F' objects @@ -336,6 +327,13 @@ private static Converte for (ConverterInfo unknownInfo : CONVERTERS) { if (fromType.isAssignableFrom(unknownInfo.getFrom()) && unknownInfo.getTo().isAssignableFrom(toType)) { ConverterInfo info = (ConverterInfo) unknownInfo; + int flags = unknownInfo.getFlags(); + if ((flags & Converter.ALLOW_UNSAFE_CASTS) == 0) { + if ((flags & Converter.NO_LEFT_CHAINING) == Converter.NO_LEFT_CHAINING) + continue; + if ((flags & Converter.NO_RIGHT_CHAINING) == Converter.NO_RIGHT_CHAINING) + continue; + } // 'from' and 'to' both don't exactly match and need to be filtered // Basically, this converter will only convert certain 'F' objects diff --git a/src/main/java/org/skriptlang/skript/lang/entry/EntryContainer.java b/src/main/java/org/skriptlang/skript/lang/entry/EntryContainer.java index 91d8fc52ba1..6c2dfb59d2d 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/EntryContainer.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/EntryContainer.java @@ -1,26 +1,9 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry; import ch.njol.skript.config.Node; import ch.njol.skript.config.SectionNode; import ch.njol.skript.lang.parser.ParserInstance; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -170,4 +153,13 @@ public Object getOptional(String key, boolean useDefaultValue) { return value; } + /** + * Check to see if an entry data with the key matching {@code key} was used. + * @param key The key to check + * @return true if an entry data with the matching key was used. + */ + public boolean hasEntry(@NotNull String key) { + return handledNodes.containsKey(key); + } + } diff --git a/src/main/java/org/skriptlang/skript/lang/entry/EntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/EntryData.java index 3787a01e74b..b6dbeecd6b8 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/EntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/EntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry; import ch.njol.skript.config.Node; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/EntryValidator.java b/src/main/java/org/skriptlang/skript/lang/entry/EntryValidator.java index c1966b89aad..f8735b076c2 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/EntryValidator.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/EntryValidator.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/KeyValueEntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/KeyValueEntryData.java index 57c157a9c01..efa814379cd 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/KeyValueEntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/KeyValueEntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/SectionEntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/SectionEntryData.java index d38a703b092..21fc561d250 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/SectionEntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/SectionEntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/util/ExpressionEntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/util/ExpressionEntryData.java index b69f8b6c7f1..166e616ec6c 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/util/ExpressionEntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/util/ExpressionEntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry.util; import ch.njol.skript.lang.Expression; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/util/LiteralEntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/util/LiteralEntryData.java index 72bdc474c18..9a317a6bc64 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/util/LiteralEntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/util/LiteralEntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry.util; import ch.njol.skript.lang.ParseContext; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/util/TriggerEntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/util/TriggerEntryData.java index a445dc438a4..7cc093e9473 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/util/TriggerEntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/util/TriggerEntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry.util; import ch.njol.skript.ScriptLoader; diff --git a/src/main/java/org/skriptlang/skript/lang/entry/util/VariableStringEntryData.java b/src/main/java/org/skriptlang/skript/lang/entry/util/VariableStringEntryData.java index 150e2098f3b..bf9d834df8c 100644 --- a/src/main/java/org/skriptlang/skript/lang/entry/util/VariableStringEntryData.java +++ b/src/main/java/org/skriptlang/skript/lang/entry/util/VariableStringEntryData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.entry.util; import ch.njol.skript.lang.VariableString; diff --git a/src/main/java/org/skriptlang/skript/lang/experiment/Experiment.java b/src/main/java/org/skriptlang/skript/lang/experiment/Experiment.java index d4067869507..55422718eb7 100644 --- a/src/main/java/org/skriptlang/skript/lang/experiment/Experiment.java +++ b/src/main/java/org/skriptlang/skript/lang/experiment/Experiment.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.experiment; import ch.njol.skript.patterns.PatternCompiler; diff --git a/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentRegistry.java b/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentRegistry.java index b115f14d57d..ec6a5ae5157 100644 --- a/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentRegistry.java +++ b/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentRegistry.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.experiment; import ch.njol.skript.Skript; diff --git a/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentSet.java b/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentSet.java index bce336ffb55..d543176dead 100644 --- a/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentSet.java +++ b/src/main/java/org/skriptlang/skript/lang/experiment/ExperimentSet.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.experiment; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/org/skriptlang/skript/lang/experiment/Experimented.java b/src/main/java/org/skriptlang/skript/lang/experiment/Experimented.java index 77c68b5e4bc..8526806f404 100644 --- a/src/main/java/org/skriptlang/skript/lang/experiment/Experimented.java +++ b/src/main/java/org/skriptlang/skript/lang/experiment/Experimented.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.experiment; import ch.njol.skript.Skript; diff --git a/src/main/java/org/skriptlang/skript/lang/experiment/LifeCycle.java b/src/main/java/org/skriptlang/skript/lang/experiment/LifeCycle.java index ff1479464af..be10c90b261 100644 --- a/src/main/java/org/skriptlang/skript/lang/experiment/LifeCycle.java +++ b/src/main/java/org/skriptlang/skript/lang/experiment/LifeCycle.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.experiment; /** diff --git a/src/main/java/org/skriptlang/skript/lang/script/ScriptData.java b/src/main/java/org/skriptlang/skript/lang/script/ScriptData.java index 58c12ac10cf..812f5e068e2 100644 --- a/src/main/java/org/skriptlang/skript/lang/script/ScriptData.java +++ b/src/main/java/org/skriptlang/skript/lang/script/ScriptData.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.script; /** diff --git a/src/main/java/org/skriptlang/skript/lang/script/ScriptWarning.java b/src/main/java/org/skriptlang/skript/lang/script/ScriptWarning.java index 10e917ad88b..ac342a8bbdd 100644 --- a/src/main/java/org/skriptlang/skript/lang/script/ScriptWarning.java +++ b/src/main/java/org/skriptlang/skript/lang/script/ScriptWarning.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.script; import ch.njol.skript.Skript; diff --git a/src/main/java/org/skriptlang/skript/lang/structure/Structure.java b/src/main/java/org/skriptlang/skript/lang/structure/Structure.java index f56cffcfbf0..145d99ecad1 100644 --- a/src/main/java/org/skriptlang/skript/lang/structure/Structure.java +++ b/src/main/java/org/skriptlang/skript/lang/structure/Structure.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.structure; import ch.njol.skript.Skript; @@ -113,7 +95,7 @@ public final boolean init(Expression[] expressions, int matchedPattern, Kleen StructureInfo structureInfo = structureData.structureInfo; assert structureInfo != null; - if (structureInfo.simple) { // simple structures do not have validators + if (structureData.node instanceof SimpleNode) { // simple structures do not have validators return init(literals, matchedPattern, parseResult, null); } @@ -206,10 +188,10 @@ public static Structure parse(String expr, Node node, @Nullable String defaultEr throw new IllegalArgumentException("only simple or section nodes may be parsed as a structure"); ParserInstance.get().getData(StructureData.class).node = node; - if (node instanceof SimpleNode) { // only allow simple structures for simple nodes - iterator = new CheckedIterator<>(iterator, item -> item != null && item.simple); - } else { // only allow non-simple structures for section nodes - iterator = new CheckedIterator<>(iterator, item -> item != null && !item.simple); + if (node instanceof SimpleNode) { // filter out section only structures + iterator = new CheckedIterator<>(iterator, item -> item != null && item.nodeType.canBeSimple()); + } else { // filter out simple only structures + iterator = new CheckedIterator<>(iterator, item -> item != null && item.nodeType.canBeSection()); } iterator = new ConsumingIterator<>(iterator, elementInfo -> ParserInstance.get().getData(StructureData.class).structureInfo = elementInfo); diff --git a/src/main/java/org/skriptlang/skript/lang/structure/StructureInfo.java b/src/main/java/org/skriptlang/skript/lang/structure/StructureInfo.java index 773c3212af3..21c7e354d16 100644 --- a/src/main/java/org/skriptlang/skript/lang/structure/StructureInfo.java +++ b/src/main/java/org/skriptlang/skript/lang/structure/StructureInfo.java @@ -1,26 +1,10 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.structure; import ch.njol.skript.lang.SyntaxElementInfo; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.skriptlang.skript.lang.entry.EntryValidator; +import org.skriptlang.skript.registration.SyntaxInfo; /** * Special {@link SyntaxElementInfo} for {@link Structure}s that may contain information such as the {@link EntryValidator}. @@ -35,20 +19,28 @@ public class StructureInfo extends SyntaxElementInfo { */ public final boolean simple; + @ApiStatus.Experimental + public final SyntaxInfo.Structure.NodeType nodeType; + public StructureInfo(String[] patterns, Class c, String originClassPath) throws IllegalArgumentException { this(patterns, c, originClassPath, false); } - public StructureInfo(String[] patterns, Class c, String originClassPath, boolean simple) throws IllegalArgumentException { - super(patterns, c, originClassPath); - this.entryValidator = null; - this.simple = simple; + public StructureInfo(String[] patterns, Class elementClass, String originClassPath, boolean simple) throws IllegalArgumentException { + this(patterns, elementClass, originClassPath, null, simple ? SyntaxInfo.Structure.NodeType.SIMPLE : SyntaxInfo.Structure.NodeType.SECTION); + } + + public StructureInfo(String[] patterns, Class elementClass, String originClassPath, @Nullable EntryValidator entryValidator) throws IllegalArgumentException { + this(patterns, elementClass, originClassPath, entryValidator, SyntaxInfo.Structure.NodeType.SECTION); } - public StructureInfo(String[] patterns, Class c, String originClassPath, EntryValidator entryValidator) throws IllegalArgumentException { - super(patterns, c, originClassPath); + @ApiStatus.Experimental + public StructureInfo(String[] patterns, Class elementClass, String originClassPath, + @Nullable EntryValidator entryValidator, SyntaxInfo.Structure.NodeType nodeType) throws IllegalArgumentException { + super(patterns, elementClass, originClassPath); this.entryValidator = entryValidator; - this.simple = false; + this.nodeType = nodeType; + this.simple = nodeType.canBeSimple(); } } diff --git a/src/main/java/org/skriptlang/skript/lang/util/Cyclical.java b/src/main/java/org/skriptlang/skript/lang/util/Cyclical.java index 7c5def1d96f..81da4411d7b 100644 --- a/src/main/java/org/skriptlang/skript/lang/util/Cyclical.java +++ b/src/main/java/org/skriptlang/skript/lang/util/Cyclical.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.lang.util; /** diff --git a/src/main/java/org/skriptlang/skript/localization/Localizer.java b/src/main/java/org/skriptlang/skript/localization/Localizer.java new file mode 100644 index 00000000000..c237dd20a83 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/localization/Localizer.java @@ -0,0 +1,66 @@ +package org.skriptlang.skript.localization; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.addon.SkriptAddon; +import org.skriptlang.skript.util.ViewProvider; + +/** + * A Localizer is used for the localization of translatable strings. + * + * This API is highly experimental and will be subject to change due to pending localization reworks. + * In its current state, it acts as a bridge between old and new API. + * + * @see ch.njol.skript.localization.Language + */ +@ApiStatus.Experimental +public interface Localizer extends ViewProvider { + + /** + * @param addon The addon this localizer is localizing for. + * @return A localizer with no default translations. + */ + @Contract("_ -> new") + static Localizer of(SkriptAddon addon) { + return new LocalizerImpl(addon); + } + + /** + * Sets the language file directories for this localizer. + * This method will initiate a loading of any language files in the provided directories. + * @param languageFileDirectory The path to the directory on the jar containing language files. + * @param dataFileDirectory The path to the directory on the disk containing language files. + * For example, this may include language files that have been saved to enable user customization. + */ + void setSourceDirectories(String languageFileDirectory, @Nullable String dataFileDirectory); + + /** + * @return The path to the directory on the jar containing language files. + */ + @Nullable String languageFileDirectory(); + + /** + * @return The path to the directory on the disk containing language files. + */ + @Nullable String dataFileDirectory(); + + /** + * Used for obtaining the translation of a language key. + * @param key The key of the translation to obtain. + * @return The translation represented by the provided key, or null if no translation exists. + */ + @Nullable String translate(String key); + + /** + * Constructs an unmodifiable view of this localizer. + * That is, no new translations may be added. + * @return An unmodifiable view of this localizer. + */ + @Override + @Contract("-> new") + default Localizer unmodifiableView() { + return new LocalizerImpl.UnmodifiableLocalizer(this); + } + +} diff --git a/src/main/java/org/skriptlang/skript/localization/LocalizerImpl.java b/src/main/java/org/skriptlang/skript/localization/LocalizerImpl.java new file mode 100644 index 00000000000..f35a9ee8eef --- /dev/null +++ b/src/main/java/org/skriptlang/skript/localization/LocalizerImpl.java @@ -0,0 +1,74 @@ +package org.skriptlang.skript.localization; + +import ch.njol.skript.SkriptAPIException; +import ch.njol.skript.localization.Language; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.addon.SkriptAddon; + +final class LocalizerImpl implements Localizer { + + private final SkriptAddon addon; + + LocalizerImpl(SkriptAddon addon) { + this.addon = addon; + } + + private String languageFileDirectory; + private String dataFileDirectory; + + @Override + public void setSourceDirectories(String languageFileDirectory, @Nullable String dataFileDirectory) { + if (this.languageFileDirectory != null) { + throw new SkriptAPIException("A localizer's source directories may only be set once."); + } + this.languageFileDirectory = languageFileDirectory; + this.dataFileDirectory = dataFileDirectory; + Language.loadDefault(addon); + } + + @Override + public @Nullable String languageFileDirectory() { + return languageFileDirectory; + } + + @Override + public @Nullable String dataFileDirectory() { + return dataFileDirectory; + } + + @Override + public @Nullable String translate(String key) { + return Language.get_(key); + } + + static final class UnmodifiableLocalizer implements Localizer { + + private final Localizer localizer; + + UnmodifiableLocalizer(Localizer localizer) { + this.localizer = localizer; + } + + @Override + public void setSourceDirectories(String languageFileDirectory, @Nullable String dataFileDirectory) { + throw new UnsupportedOperationException("Cannot set the source directories of an unmodifiable Localizer."); + } + + @Override + public @Nullable String languageFileDirectory() { + return localizer.languageFileDirectory(); + } + + @Override + public @Nullable String dataFileDirectory() { + return localizer.dataFileDirectory(); + } + + @Override + public @Nullable String translate(String key) { + return localizer.translate(key); + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfos.java b/src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfos.java new file mode 100644 index 00000000000..49eefd4afba --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfos.java @@ -0,0 +1,183 @@ +package org.skriptlang.skript.registration; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.lang.entry.EntryValidator; +import org.skriptlang.skript.registration.DefaultSyntaxInfosImpl.ExpressionImpl; +import org.skriptlang.skript.registration.DefaultSyntaxInfosImpl.StructureImpl; + +/** + * This class is not safe to be directly referenced. + * Use {@link SyntaxInfo} instead. + */ +@ApiStatus.Internal +@ApiStatus.Experimental +public interface DefaultSyntaxInfos { + + /** + * A syntax info to be used for {@link ch.njol.skript.lang.Expression}s. + * It differs from a typical info in that it also has a return type. + * @param The class providing the implementation of the Expression this info represents. + * @param The type of the return type of the Expression. + */ + @ApiStatus.Experimental + interface Expression, R> extends SyntaxInfo { + + /** + * Constructs a builder for an expression syntax info. + * @param expressionClass The Expression class the info will represent. + * @param returnType The class representing the supertype of all values the Expression may return. + * @return An Expression-specific builder for creating a syntax info representing expressionClass. + * @param The class providing the implementation of the Expression this info represents. + * @param The supertype of all values the Expression may return. + */ + @Contract("_, _ -> new") + static , R> Builder, E, R> builder( + Class expressionClass, Class returnType) { + return new ExpressionImpl.BuilderImpl<>(expressionClass, returnType); + } + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Builder, E, R> builder(); + + /** + * @return The class representing the supertype of all values the Expression may return. + */ + Class returnType(); + + /** + * An Expression-specific builder is used for constructing a new Expression syntax info. + * @see #builder(Class) + * @param The type of builder being used. + * @param The Expression class providing the implementation of the syntax info being built. + * @param The type of the return type of the Expression. + */ + interface Builder, E extends ch.njol.skript.lang.Expression, R> extends SyntaxInfo.Builder { + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Expression build(); + + } + + } + + /** + * A syntax info to be used for {@link org.skriptlang.skript.lang.structure.Structure}s. + * It contains additional details including the {@link EntryValidator} to use, if any. + * @param The class providing the implementation of the Structure this info represents. + */ + @ApiStatus.Experimental + interface Structure extends SyntaxInfo { + + /** + * Represents type of {@link ch.njol.skript.config.Node}s that can represent a Structure. + */ + enum NodeType { + + /** + * For Structures that can be represented using a {@link ch.njol.skript.config.SimpleNode}. + */ + SIMPLE, + + /** + * For Structures that can be represented using a {@link ch.njol.skript.config.SectionNode}. + */ + SECTION, + + /** + * For Structures that can be represented using a + * {@link ch.njol.skript.config.SimpleNode} or {@link ch.njol.skript.config.SectionNode}. + */ + BOTH; + + /** + * @return Whether a Structure of this type can be represented using a {@link ch.njol.skript.config.SimpleNode}. + */ + public boolean canBeSimple() { + return this != SECTION; + } + + /** + * @return Whether a Structure of this type can be represented using a {@link ch.njol.skript.config.SectionNode}. + */ + public boolean canBeSection() { + return this != SIMPLE; + } + + } + + /** + * Constructs a builder for a structure syntax info. + * @param structureClass The Structure class the info will represent. + * @return A Structure-specific builder for creating a syntax info representing structureClass. + * By default, the {@link #nodeType()} of the builder is {@link NodeType#SECTION}. + * @param The class providing the implementation of the Structure this info represents. + */ + @Contract("_ -> new") + static Builder, E> builder(Class structureClass) { + return new StructureImpl.BuilderImpl<>(structureClass); + } + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Builder, E> builder(); + + /** + * @return The entry validator to use for handling the Structure's entries. + * If null, the Structure is expected to manually handle any entries. + */ + @Nullable EntryValidator entryValidator(); + + /** + * @return The type of {@link ch.njol.skript.config.Node}s that can represent the Structure. + */ + NodeType nodeType(); + + /** + * A Structure-specific builder is used for constructing a new Structure syntax info. + * @see #builder(Class) + * @param The type of builder being used. + * @param The Structure class providing the implementation of the syntax info being built. + */ + interface Builder, E extends org.skriptlang.skript.lang.structure.Structure> extends SyntaxInfo.Builder { + + /** + * Sets the entry validator the Structure will use for handling entries. + * @param entryValidator The entry validator to use. + * @return This builder. + * @see Structure#entryValidator() + */ + @Contract("_ -> this") + B entryValidator(EntryValidator entryValidator); + + /** + * Sets the type of {@link ch.njol.skript.config.Node}s that can represent the Structure. + * @return This builder. + * @see Structure#type() + */ + B nodeType(NodeType type); + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Structure build(); + + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfosImpl.java b/src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfosImpl.java new file mode 100644 index 00000000000..19be1dbc3ef --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfosImpl.java @@ -0,0 +1,200 @@ +package org.skriptlang.skript.registration; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import org.jetbrains.annotations.Nullable; +import org.skriptlang.skript.lang.entry.EntryValidator; +import org.skriptlang.skript.util.Priority; + +import java.util.Collection; +import java.util.Objects; +import java.util.function.Supplier; + +final class DefaultSyntaxInfosImpl { + + /** + * {@inheritDoc} + */ + static class ExpressionImpl, R> + extends SyntaxInfoImpl implements DefaultSyntaxInfos.Expression { + + private final Class returnType; + + ExpressionImpl( + SyntaxOrigin origin, Class type, @Nullable Supplier supplier, + Collection patterns, Priority priority, @Nullable Class returnType + ) { + super(origin, type, supplier, patterns, priority); + Preconditions.checkNotNull(returnType, "An expression syntax info must have a return type."); + this.returnType = returnType; + } + + @Override + public Expression.Builder, E, R> builder() { + var builder = new BuilderImpl<>(type(), returnType); + super.builder().applyTo(builder); + return builder; + } + + @Override + public Class returnType() { + return returnType; + } + + @Override + public boolean equals(Object other) { + return other instanceof Expression expression && + super.equals(other) && + returnType() == expression.returnType(); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), returnType()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("origin", origin()) + .add("type", type()) + .add("patterns", patterns()) + .add("priority", priority()) + .add("returnType", returnType()) + .toString(); + } + + /** + * {@inheritDoc} + */ + static final class BuilderImpl, E extends ch.njol.skript.lang.Expression, R> + extends SyntaxInfoImpl.BuilderImpl + implements Expression.Builder { + + private final Class returnType; + + BuilderImpl(Class expressionClass, Class returnType) { + super(expressionClass); + this.returnType = returnType; + } + + public Expression build() { + return new ExpressionImpl<>(origin, type, supplier, patterns, priority, returnType); + } + } + + } + + /** + * {@inheritDoc} + */ + static class StructureImpl + extends SyntaxInfoImpl implements DefaultSyntaxInfos.Structure { + + private final @Nullable EntryValidator entryValidator; + private final NodeType nodeType; + + StructureImpl( + SyntaxOrigin origin, Class type, @Nullable Supplier supplier, + Collection patterns, Priority priority, + @Nullable EntryValidator entryValidator, NodeType nodeType + ) { + super(origin, type, supplier, patterns, priority); + if (!nodeType.canBeSection() && entryValidator != null) + throw new IllegalArgumentException("Simple Structures cannot have an EntryValidator"); + this.entryValidator = entryValidator; + this.nodeType = nodeType; + } + + @Override + public Structure.Builder, E> builder() { + var builder = new BuilderImpl<>(type()); + super.builder().applyTo(builder); + if (entryValidator != null) { + builder.entryValidator(entryValidator); + } + builder.nodeType(nodeType); + return builder; + } + + @Override + public @Nullable EntryValidator entryValidator() { + return entryValidator; + } + + @Override + public NodeType nodeType() { + return nodeType; + } + + @Override + public boolean equals(Object other) { + return other instanceof Structure structure && + super.equals(other) && + Objects.equals(entryValidator(), structure.entryValidator()) && + Objects.equals(nodeType(), structure.nodeType()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), entryValidator(), nodeType()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("origin", origin()) + .add("type", type()) + .add("patterns", patterns()) + .add("priority", priority()) + .add("entryValidator", entryValidator()) + .toString(); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + static final class BuilderImpl, E extends org.skriptlang.skript.lang.structure.Structure> + extends SyntaxInfoImpl.BuilderImpl + implements Structure.Builder { + + private @Nullable EntryValidator entryValidator; + private NodeType nodeType = NodeType.SECTION; + + BuilderImpl(Class structureClass) { + super(structureClass); + } + + @Override + public B entryValidator(EntryValidator entryValidator) { + this.entryValidator = entryValidator; + return (B) this; + } + + @Override + public B nodeType(NodeType nodeType) { + this.nodeType = nodeType; + return (B) this; + } + + public Structure build() { + return new StructureImpl<>(origin, type, supplier, patterns, priority, entryValidator, nodeType); + } + + @Override + public void applyTo(SyntaxInfo.Builder builder) { + super.applyTo(builder); + //noinspection rawtypes - Should be safe, generics will not influence this + if (builder instanceof Structure.Builder structureBuilder) { + if (entryValidator != null) { + structureBuilder.entryValidator(entryValidator); + structureBuilder.nodeType(nodeType); + } + } + } + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/SyntaxInfo.java b/src/main/java/org/skriptlang/skript/registration/SyntaxInfo.java new file mode 100644 index 00000000000..f1a70785580 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/SyntaxInfo.java @@ -0,0 +1,173 @@ +package org.skriptlang.skript.registration; + +import ch.njol.skript.lang.SyntaxElement; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.registration.SyntaxInfoImpl.BuilderImpl; +import org.skriptlang.skript.util.Builder.Buildable; +import org.skriptlang.skript.util.Priority; + +import java.util.Collection; +import java.util.function.Supplier; + +/** + * A syntax info contains the details of a syntax, including its origin and patterns. + * @param The class providing the implementation of the syntax this info represents. + */ +@ApiStatus.Experimental +public interface SyntaxInfo extends Buildable, SyntaxInfo>, DefaultSyntaxInfos { + + /** + * A priority for infos with patterns that only match simple text (they do not have any {@link Expression}s). + * Example: "[the] console" + */ + Priority SIMPLE = Priority.base(); + + /** + * A priority for infos with patterns that contain at least one {@link Expression}. + * This is typically the default priority of an info. + * Example: "[the] first %number% characters of %strings%" + */ + Priority COMBINED = Priority.after(SIMPLE); + + /** + * A priority for infos with patterns that can match almost anything. + * This is likely the case when using regex or multiple expressions next to each other in a pattern. + * Example: "[the] [loop-]<.+>" + */ + Priority PATTERN_MATCHES_EVERYTHING = Priority.after(COMBINED); + + /** + * Constructs a builder for a syntax info. + * @param type The syntax class the info will represent. + * @return A builder for creating a syntax info representing type. + */ + @Contract("_ -> new") + static Builder, E> builder(Class type) { + return new BuilderImpl<>(type); + } + + /** + * {@inheritDoc} + */ + @Override + @Contract("-> new") + Builder, E> builder(); + + /** + * @return The origin of this syntax. + */ + SyntaxOrigin origin(); + + /** + * @return The class providing the implementation of this syntax. + */ + Class type(); + + /** + * @return A new instance of the class providing the implementation of this syntax. + */ + @Contract("-> new") + E instance(); + + /** + * @return The patterns of this syntax. + */ + @Unmodifiable Collection patterns(); + + /** + * @return The priority of this syntax, which dictates its position for matching during parsing. + */ + Priority priority(); + + /** + * A builder is used for constructing a new syntax info. + * @see #builder(Class) + * @param The type of builder being used. + * @param The class providing the implementation of the syntax info being built. + */ + interface Builder, E extends SyntaxElement> extends org.skriptlang.skript.util.Builder, SyntaxInfo> { + + /** + * Sets the origin the syntax info will use. + * @param origin The origin to use. + * @return This builder. + * @see SyntaxInfo#origin() + */ + @Contract("_ -> this") + B origin(SyntaxOrigin origin); + + /** + * Sets the supplier the syntax info will use to create new instances of the implementing class. + * @param supplier The supplier to use. + * @return This builder. + * @see SyntaxInfo#instance() + */ + @Contract("_ -> this") + B supplier(Supplier supplier); + + /** + * Adds a new pattern to the syntax info. + * @param pattern The pattern to add. + * @return This builder. + * @see SyntaxInfo#patterns() + */ + @Contract("_ -> this") + B addPattern(String pattern); + + /** + * Adds new patterns to the syntax info. + * @param patterns The patterns to add. + * @return This builder. + * @see SyntaxInfo#patterns() + */ + @Contract("_ -> this") + B addPatterns(String... patterns); + + /** + * Adds new patterns to the syntax info. + * @param patterns The patterns to add. + * @return This builder. + * @see SyntaxInfo#patterns() + */ + @Contract("_ -> this") + B addPatterns(Collection patterns); + + /** + * Removes all patterns from the syntax info. + * @return This builder. + * @see SyntaxInfo#patterns() + */ + @Contract("-> this") + B clearPatterns(); + + /** + * Sets the priority the syntax info will use, which dictates its position for matching during parsing. + * @param priority The priority to use. + * @return This builder. + */ + @Contract("_ -> this") + B priority(Priority priority); + + /** + * Builds a new syntax info from the set details. + * @return A syntax info representing the class providing the syntax's implementation. + */ + @Contract("-> new") + SyntaxInfo build(); + + /** + * Applies the values of this builder onto builder. + * When using this method, it is possible that some values are not safe to copy over. + * For example, when applying a SyntaxInfo for some type to a SyntaxInfo of another type, + * it is *not* safe to copy over {@link #supplier(Supplier)}, but that operation will occur anyway. + * In cases like this, you are expected to correct the values. + * @param builder The builder to apply values onto. + */ + @Override + void applyTo(Builder builder); + + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/SyntaxInfoImpl.java b/src/main/java/org/skriptlang/skript/registration/SyntaxInfoImpl.java new file mode 100644 index 00000000000..9b1de224549 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/SyntaxInfoImpl.java @@ -0,0 +1,198 @@ +package org.skriptlang.skript.registration; + +import ch.njol.skript.lang.SyntaxElement; +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.util.ClassUtils; +import org.skriptlang.skript.util.Priority; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.function.Supplier; + +class SyntaxInfoImpl implements SyntaxInfo { + + private final SyntaxOrigin origin; + private final Class type; + private final @Nullable Supplier supplier; + private final Collection patterns; + private final Priority priority; + + protected SyntaxInfoImpl( + SyntaxOrigin origin, Class type, @Nullable Supplier supplier, + Collection patterns, Priority priority + ) { + Preconditions.checkArgument(supplier != null || ClassUtils.isNormalClass(type), + "Failed to register a syntax info for '" + type.getName() + "'." + + " Element classes must be a normal type unless a supplier is provided."); + Preconditions.checkArgument(!patterns.isEmpty(), + "Failed to register a syntax info for '" + type.getName() + "'." + + " There must be at least one pattern."); + this.origin = origin; + this.type = type; + this.supplier = supplier; + this.patterns = ImmutableList.copyOf(patterns); + this.priority = priority; + } + + @Override + public Builder, T> builder() { + var builder = new BuilderImpl<>(type); + builder.origin(origin); + if (supplier != null) { + builder.supplier(supplier); + } + builder.addPatterns(patterns); + builder.priority(priority); + return builder; + } + + @Override + public SyntaxOrigin origin() { + return origin; + } + + @Override + public Class type() { + return type; + } + + @Override + public T instance() { + try { + return supplier == null ? type.getDeclaredConstructor().newInstance() : supplier.get(); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + } + + @Override + public @Unmodifiable Collection patterns() { + return patterns; + } + + @Override + public Priority priority() { + return priority; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + return other instanceof SyntaxInfo info && + Objects.equals(origin(), info.origin()) && + Objects.equals(type(), info.type()) && + Objects.equals(patterns(), info.patterns()) && + Objects.equals(priority(), info.priority()); + } + + @Override + public int hashCode() { + return Objects.hash(origin(), type(), patterns(), priority()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("origin", origin()) + .add("type", type()) + .add("patterns", patterns()) + .add("priority", priority()) + .toString(); + } + + @SuppressWarnings("unchecked") + static class BuilderImpl, E extends SyntaxElement> implements Builder { + + /** + * A default origin that describes the class of a syntax. + */ + private static final class ClassOrigin implements SyntaxOrigin { + + private final String name; + + ClassOrigin(Class clazz) { + this.name = clazz.getName(); + } + + @Override + public String name() { + return name; + } + + } + + final Class type; + SyntaxOrigin origin; + @Nullable Supplier supplier; + final List patterns = new ArrayList<>(); + Priority priority = SyntaxInfo.COMBINED; + + BuilderImpl(Class type) { + this.type = type; + origin = new ClassOrigin(type); + } + + public B origin(SyntaxOrigin origin) { + this.origin = origin; + return (B) this; + } + + public B supplier(Supplier supplier) { + this.supplier = supplier; + return (B) this; + } + + public B addPattern(String pattern) { + this.patterns.add(pattern); + return (B) this; + } + + public B addPatterns(String... patterns) { + Collections.addAll(this.patterns, patterns); + return (B) this; + } + + public B addPatterns(Collection patterns) { + this.patterns.addAll(patterns); + return (B) this; + } + + @Override + public B clearPatterns() { + this.patterns.clear(); + return (B) this; + } + + @Override + public B priority(Priority priority) { + this.priority = priority; + return (B) this; + } + + public SyntaxInfo build() { + return new SyntaxInfoImpl<>(origin, type, supplier, patterns, priority); + } + + @Override + public void applyTo(Builder builder) { + builder.origin(origin); + if (supplier != null) { + //noinspection rawtypes - Let's hope the user knows what they are doing... + builder.supplier((Supplier) supplier); + } + builder.addPatterns(patterns); + builder.priority(priority); + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/SyntaxOrigin.java b/src/main/java/org/skriptlang/skript/registration/SyntaxOrigin.java new file mode 100644 index 00000000000..b5e8aa9d552 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/SyntaxOrigin.java @@ -0,0 +1,60 @@ +package org.skriptlang.skript.registration; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.skriptlang.skript.addon.SkriptAddon; + +/** + * The origin of a syntax, currently only used for documentation purposes. + */ +@FunctionalInterface +@ApiStatus.Experimental +public interface SyntaxOrigin { + + /** + * Constructs a syntax origin from an addon. + * @param addon The addon to construct this origin from. + * @return An origin pointing to the provided addon. + */ + @Contract("_ -> new") + static SyntaxOrigin of(SkriptAddon addon) { + return new AddonOrigin(addon); + } + + /** + * A basic origin describing the addon a syntax has originated from. + * @see SyntaxOrigin#of(SkriptAddon) + */ + final class AddonOrigin implements SyntaxOrigin { + + private final SkriptAddon addon; + + private AddonOrigin(SkriptAddon addon) { + this.addon = addon.unmodifiableView(); + } + + /** + * @return A string representing the name of the addon this origin describes. + * Equivalent to {@link SkriptAddon#name()}. + */ + @Override + public String name() { + return addon.name(); + } + + /** + * @return An unmodifiable view of the addon this origin describes. + * @see SkriptAddon#unmodifiableView() + */ + public SkriptAddon addon() { + return addon; + } + + } + + /** + * @return A string representing this origin. + */ + String name(); + +} diff --git a/src/main/java/org/skriptlang/skript/registration/SyntaxRegister.java b/src/main/java/org/skriptlang/skript/registration/SyntaxRegister.java new file mode 100644 index 00000000000..e8ab2bb3b0b --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/SyntaxRegister.java @@ -0,0 +1,41 @@ +package org.skriptlang.skript.registration; + +import com.google.common.collect.ImmutableSet; + +import java.util.Collection; +import java.util.Comparator; +import java.util.Set; +import java.util.concurrent.ConcurrentSkipListSet; + +/** + * A syntax register is a collection of registered {@link SyntaxInfo}s of a common type. + * @param The type of syntax in this register. + */ +final class SyntaxRegister> { + + private static final Comparator> SET_COMPARATOR = (a,b) -> { + if (a == b) { // only considered equal if registering the same infos + return 0; + } + int result = a.priority().compareTo(b.priority()); + // when elements have the same priority, the oldest element comes first + return result != 0 ? result : 1; + }; + + final Set syntaxes = new ConcurrentSkipListSet<>(SET_COMPARATOR); + + public Collection syntaxes() { + synchronized (syntaxes) { + return ImmutableSet.copyOf(syntaxes); + } + } + + public void add(I info) { + syntaxes.add(info); + } + + public void remove(I info) { + syntaxes.remove(info); + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/SyntaxRegistry.java b/src/main/java/org/skriptlang/skript/registration/SyntaxRegistry.java new file mode 100644 index 00000000000..acde00a843f --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/SyntaxRegistry.java @@ -0,0 +1,158 @@ +package org.skriptlang.skript.registration; + +import ch.njol.skript.lang.Condition; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.Section; +import ch.njol.skript.lang.Statement; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; +import org.skriptlang.skript.lang.structure.Structure; +import org.skriptlang.skript.util.Registry; +import org.skriptlang.skript.util.ViewProvider; + +import java.util.Collection; + +/** + * A syntax registry manages all {@link SyntaxRegister}s for syntax registration. + */ +@ApiStatus.Experimental +public interface SyntaxRegistry extends ViewProvider, Registry> { + + /** + * A key representing the built-in {@link Structure} syntax element. + */ + Key> STRUCTURE = Key.of("structure"); + + /** + * A key representing the built-in {@link Section} syntax element. + */ + Key> SECTION = Key.of("section"); + + /** + * A key representing all {@link Statement} syntax elements. + * By default, this includes {@link #EFFECT} and {@link #CONDITION}. + */ + Key> STATEMENT = Key.of("statement"); + + /** + * A key representing the built-in {@link Effect} syntax element. + */ + Key> EFFECT = ChildKey.of(STATEMENT, "effect"); + + /** + * A key representing the built-in {@link Condition} syntax element. + */ + Key> CONDITION = ChildKey.of(STATEMENT, "condition"); + + /** + * A key representing the built-in {@link Expression} syntax element. + */ + Key> EXPRESSION = Key.of("expression"); + + /** + * Constructs a default implementation of a syntax registry. + * This implementation is practically a wrapper around {@code Map, SyntaxRegistry>}. + * @return A syntax registry containing no elements. + */ + @Contract("-> new") + static SyntaxRegistry empty() { + return new SyntaxRegistryImpl(); + } + + /** + * A method to obtain all syntaxes registered under a certain key. + * @param key The key to obtain syntaxes from. + * @return An unmodifiable snapshot of all syntaxes registered under key. + * @param The syntax type. + */ + > @Unmodifiable Collection syntaxes(Key key); + + /** + * Registers a new syntax under a provided key. + * @param key The key to register info under. + * @param info The syntax info to register. + * @param The syntax type. + */ + > void register(Key key, I info); + + /** + * Unregisters a syntax registered under a provided key. + * @param key The key the info is registered under. + * @param info The syntax info to unregister. + * @param The syntax type. + */ + > void unregister(Key key, I info); + + /** + * Constructs an unmodifiable view of this syntax registry. + * That is, the returned registry will not allow registrations. + * @return An unmodifiable view of this syntax registry. + */ + @Override + @Contract("-> new") + default SyntaxRegistry unmodifiableView() { + return new SyntaxRegistryImpl.UnmodifiableRegistry(this); + } + + /** + * {@inheritDoc} + * There are no guarantees on the ordering of the returned collection. + * @return An unmodifiable snapshot of all syntaxes registered. + */ + @Override + @Unmodifiable Collection> elements(); + + /** + * Represents a syntax element type. + * @param The syntax type. + */ + @ApiStatus.Experimental + interface Key> { + + /** + * @param name The name of this key. + * @return A default key implementation. + * @param The syntax type. + */ + @Contract("_ -> new") + static > Key of(String name) { + return new SyntaxRegistryImpl.KeyImpl<>(name); + } + + /** + * @return The name of the syntax element this key represents. + */ + String name(); + + } + + /** + * Like a {@link Key}, but it has a parent which causes elements to be registered to itself and its parent. + * @param The child key's syntax type. + * @param

The parent key's syntax type. + */ + @ApiStatus.Experimental + interface ChildKey> extends Key { + + /** + * @param parent The parent of this key. + * @param name The name of this key. + * @return A default child key implementation. + * @param The child key's syntax type. + * @param

The parent key's syntax type. + */ + @Contract("_, _ -> new") + static > Key of(Key

parent, String name) { + return new SyntaxRegistryImpl.ChildKeyImpl<>(parent, name); + } + + /** + * @return The parent key of this child key. + */ + Key

parent(); + + } + +} diff --git a/src/main/java/org/skriptlang/skript/registration/SyntaxRegistryImpl.java b/src/main/java/org/skriptlang/skript/registration/SyntaxRegistryImpl.java new file mode 100644 index 00000000000..843a1061697 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/registration/SyntaxRegistryImpl.java @@ -0,0 +1,156 @@ +package org.skriptlang.skript.registration; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableSet; +import org.jetbrains.annotations.Unmodifiable; + +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +final class SyntaxRegistryImpl implements SyntaxRegistry { + + private final Map, SyntaxRegister> registers = new ConcurrentHashMap<>(); + + @Override + @Unmodifiable + public > Collection syntaxes(Key key) { + return register(key).syntaxes(); + } + + @Override + public > void register(Key key, I info) { + register(key).add(info); + if (key instanceof ChildKey) { + register(((ChildKey) key).parent(), info); + } + } + + @Override + public > void unregister(Key key, I info) { + register(key).remove(info); + if (key instanceof ChildKey) { + unregister(((ChildKey) key).parent(), info); + } + } + + @SuppressWarnings("unchecked") + private > SyntaxRegister register(Key key) { + return (SyntaxRegister) registers.computeIfAbsent(key, k -> new SyntaxRegister<>()); + } + + @Override + public Collection> elements() { + ImmutableSet.Builder> builder = ImmutableSet.builder(); + registers.values().forEach(register -> { + synchronized (register.syntaxes) { + builder.addAll(register.syntaxes); + } + }); + return builder.build(); + } + + static final class UnmodifiableRegistry implements SyntaxRegistry { + + private final SyntaxRegistry registry; + + UnmodifiableRegistry(SyntaxRegistry registry) { + this.registry = registry; + } + + @Override + public @Unmodifiable Collection> elements() { + return registry.elements(); + } + + @Override + public @Unmodifiable > Collection syntaxes(Key key) { + return registry.syntaxes(key); + } + + @Override + public > void register(Key key, I info) { + throw new UnsupportedOperationException("Cannot register syntax infos with an unmodifiable syntax registry."); + } + + @Override + public > void unregister(Key key, I info) { + throw new UnsupportedOperationException("Cannot unregister syntax infos from an unmodifiable syntax registry."); + } + + } + + static class KeyImpl> implements Key { + + protected final String name; + + KeyImpl(String name) { + this.name = name; + } + + @Override + public String name() { + return name; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + return other instanceof Key key && + name().equals(key.name()); + } + + @Override + public int hashCode() { + return name().hashCode(); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("name", name()) + .toString(); + } + + } + + static final class ChildKeyImpl> extends KeyImpl implements ChildKey { + + private final Key

parent; + + ChildKeyImpl(Key

parent, String name) { + super(name); + this.parent = parent; + } + + @Override + public Key

parent() { + return parent; + } + + @Override + public boolean equals(Object other) { + return other instanceof ChildKey key && + super.equals(other) && + parent().equals(key.parent()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), parent()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("name", name()) + .add("parent", parent()) + .toString(); + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/util/Builder.java b/src/main/java/org/skriptlang/skript/util/Builder.java new file mode 100644 index 00000000000..e3280fbdf8e --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/Builder.java @@ -0,0 +1,42 @@ +package org.skriptlang.skript.util; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +/** + * An interface providing common methods to be implemented for any builder. + * + * @param The type of builder being used. + * @param The type of object being built. + */ +@ApiStatus.Experimental +public interface Builder, T> { + + /** + * Represents an object that can be converted back into a builder. + * @param The type of builder being used. + * @param The type of object being built. + */ + interface Buildable, T> { + + /** + * @return A builder representing this object. + */ + @Contract("-> new") + B builder(); + + } + + /** + * @return An object of T built from the values specified by this builder. + */ + @Contract("-> new") + T build(); + + /** + * Applies the values of this builder onto builder. + * @param builder The builder to apply values onto. + */ + void applyTo(B builder); + +} diff --git a/src/main/java/org/skriptlang/skript/util/ClassLoader.java b/src/main/java/org/skriptlang/skript/util/ClassLoader.java new file mode 100644 index 00000000000..030f6538e37 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/ClassLoader.java @@ -0,0 +1,279 @@ +package org.skriptlang.skript.util; + +import ch.njol.skript.Skript; +import ch.njol.util.StringUtils; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ResourceInfo; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.TreeSet; +import java.util.function.Consumer; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Collectors; + +/** + * A utility class for loading classes contained in specific packages. + */ +public class ClassLoader { + + /** + * @return A builder for creating a loader. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A utility method for loading and initializing all classes within the base package/subpackages. + * This method will perform a deep search, meaning classes within subpackages of subpackages will be initialized too. + * @param source A class within the resource classes should be loaded from. + * @param jarFile A file representing the jar to search for classes. + * @param basePackage The package within the jar to load classes from. + * @param subPackages The specific subpackages within basePackage to load. + * If not provided, classes within basePackage and all of its subpackages will be loaded. + */ + public static void loadClasses(Class source, File jarFile, String basePackage, String... subPackages) { + builder() + .basePackage(basePackage) + .addSubPackages(subPackages) + .initialize(true) + .deep(true) + .build() + .loadClasses(source, jarFile); + } + + private final String basePackage; + private final Collection subPackages; + private final boolean initialize; + private final boolean deep; + private final @Nullable Consumer> forEachClass; + + private ClassLoader(String basePackage, Collection subPackages, boolean initialize, + boolean deep, @Nullable Consumer> forEachClass) { + if (basePackage.isEmpty()) { + throw new IllegalArgumentException("The base package must be set"); + } + this.basePackage = basePackage.replace('.', '/') + "/"; + this.subPackages = subPackages.stream() + .map(subPackage -> subPackage.replace('.', '/') + "/") + .collect(Collectors.toSet()); + this.initialize = initialize; + this.deep = deep; + this.forEachClass = forEachClass; + } + + /** + * Loads all classes (from the provided source) meeting the criteria set by this loader. + * It is recommended to use one of the methods that also accept a [jar] file + * ({@link #loadClasses(Class, File)} and {@link #loadClasses(Class, JarFile)}) for increased reliability. + * @param source A class within the resource classes should be loaded from. + */ + public void loadClasses(Class source) { + loadClasses(source, (JarFile) null); + } + + /** + * Loads all classes (from the provided source) meeting the criteria set by this loader. + * @param source A class within the resource classes should be loaded from. + * @param jarFile A file representing the jar to search for classes. While it is possible to load the classes without a jar, + * it is recommended to provide one for reliability. + * @see #loadClasses(Class, JarFile) + */ + public void loadClasses(Class source, File jarFile) { + try (JarFile jar = new JarFile(jarFile)) { + loadClasses(source, jar); + } catch (IOException e) { + // TODO better logging + Skript.warning("Failed to access jar file: " + e); + loadClasses(source); // try to load using just the source class + } + } + + /** + * Loads all classes (from the provided source) meeting the criteria set by this loader. + * @param source A class within the resource classes should be loaded from. + * @param jar A jar to search for classes. While it is possible to load the classes without this jar, + * it is recommended to provide one for reliability. + * @see #loadClasses(Class, File) + */ + public void loadClasses(Class source, @Nullable JarFile jar) { + final Collection classPaths; + try { + if (jar != null) { // load from jar if available + classPaths = jar.stream() + .map(JarEntry::getName) + .collect(Collectors.toSet()); + } else { + classPaths = ClassPath.from(source.getClassLoader()).getResources().stream() + .map(ResourceInfo::getResourceName) + .collect(Collectors.toSet()); + } + } catch (IOException e) { + throw new RuntimeException("Failed to load classes: " + e); + } + + // Used for tracking valid classes if a non-recursive search is done + // Depth is the measure of how "deep" from the head package of 'basePackage' a class is + final int expectedDepth = !this.deep ? StringUtils.count(this.basePackage, '/') : 0; + final int offset = this.basePackage.length(); + + // classes will be loaded in alphabetical order + Collection classNames = new TreeSet<>(String::compareToIgnoreCase); + for (String name : classPaths) { + if (!name.startsWith(this.basePackage) || !name.endsWith(".class") || name.endsWith("package-info.class")) + continue; + boolean load; + if (this.subPackages.isEmpty()) { + // loaded only if within base package when deep searches are forbidden + load = this.deep || StringUtils.count(name, '/') == expectedDepth; + } else { + load = false; + for (String subPackage : this.subPackages) { + // if the entry is within the subpackage, ensure it is not any deeper if not permitted + if (name.startsWith(subPackage, offset) + && (this.deep || StringUtils.count(name, '/') == expectedDepth + StringUtils.count(subPackage, '/'))) { + load = true; + break; + } + } + } + + if (load) { + // replace separators and .class extension + classNames.add(name.replace('/', '.').substring(0, name.length() - 6)); + } + } + + java.lang.ClassLoader loader = source.getClassLoader(); + for (String className : classNames) { + try { + Class clazz = Class.forName(className, this.initialize, loader); + if (this.forEachClass != null) + this.forEachClass.accept(clazz); + } catch (ClassNotFoundException ex) { + throw new RuntimeException("Failed to load class: " + className, ex); + } catch (ExceptionInInitializerError err) { + throw new RuntimeException(className + " generated an exception while loading", err.getCause()); + } + } + } + + /** + * A builder for constructing a {@link ClassLoader}. + */ + public static final class Builder { + + private String basePackage = ""; + private final Collection subPackages = new HashSet<>(); + private boolean initialize; + private boolean deep; + private @Nullable Consumer> forEachClass; + + private Builder() { } + + /** + * Sets the package the loader should start loading classes from. + * This is required. + * @param basePackage A string representing package to start loading classes from. + * @return This builder. + */ + @Contract("_ -> this") + public Builder basePackage(String basePackage) { + this.basePackage = basePackage; + return this; + } + + /** + * Adds a subpackage the loader should start loading classes from. + * This is useful for when you may want to load from some, but not all, of the subpackages of the base package. + * @param subPackage A string representing a subpackage to load from. + * @return This builder. + * @see #addSubPackages(String...) + * @see #addSubPackages(Collection) + */ + @Contract("_ -> this") + public Builder addSubPackage(String subPackage) { + this.subPackages.add(subPackage); + return this; + } + + /** + * Adds subpackages the loader should start loading classes from. + * This is useful for when you may want to load from some, but not all, of the subpackages of the base package. + * @param subPackages Strings representing subpackages to load from. + * @return This builder. + * @see #addSubPackage(String) + * @see #addSubPackages(Collection) + */ + @Contract("_ -> this") + public Builder addSubPackages(String... subPackages) { + Collections.addAll(this.subPackages, subPackages); + return this; + } + + /** + * Adds subpackages the loader should start loading classes from. + * This is useful for when you may want to load from some, but not all, of the subpackages of the base package. + * @param subPackages Strings representing subpackages to load from. + * @return This builder. + * @see #addSubPackage(String) + * @see #addSubPackages(String...) + */ + @Contract("_ -> this") + public Builder addSubPackages(Collection subPackages) { + this.subPackages.addAll(subPackages); + return this; + } + + /** + * Sets whether the loader will initialize found classes. + * @param initialize Whether classes should be initialized when found. + * @return This builder. + */ + @Contract("_ -> this") + public Builder initialize(boolean initialize) { + this.initialize = initialize; + return this; + } + + /** + * Sets whether the loader will perform a deep search. + * @param deep Whether subpackages of the provided base package (or subpackages) should be searched. + * @return This builder. + */ + @Contract("_ -> this") + public Builder deep(boolean deep) { + this.deep = deep; + return this; + } + + /** + * Sets a consumer to be run for each found class. + * @param forEachClass A consumer to run for each found class. + * @return This builder. + */ + @Contract("_ -> this") + public Builder forEachClass(Consumer> forEachClass) { + this.forEachClass = forEachClass; + return this; + } + + /** + * Builds a new loader from the set details. + * @return A loader for loading classes through the manner outlined by this builder. + */ + @Contract("-> new") + public ClassLoader build() { + return new ClassLoader(basePackage, subPackages, initialize, deep, forEachClass); + } + + } + +} diff --git a/src/main/java/org/skriptlang/skript/util/ClassUtils.java b/src/main/java/org/skriptlang/skript/util/ClassUtils.java new file mode 100644 index 00000000000..9315f9b14b3 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/ClassUtils.java @@ -0,0 +1,19 @@ +package org.skriptlang.skript.util; + +import java.lang.reflect.Modifier; + +/** + * Utilities for interacting with classes. + */ +public final class ClassUtils { + + /** + * @param clazz The class to check. + * @return True if clazz does not represent an annotation, array, primitive, interface, or abstract class. + */ + public static boolean isNormalClass(Class clazz) { + return !clazz.isAnnotation() && !clazz.isArray() && !clazz.isPrimitive() + && !clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers()); + } + +} diff --git a/src/main/java/org/skriptlang/skript/util/Priority.java b/src/main/java/org/skriptlang/skript/util/Priority.java new file mode 100644 index 00000000000..a5f71a5c932 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/Priority.java @@ -0,0 +1,55 @@ +package org.skriptlang.skript.util; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Unmodifiable; + +import java.util.Collection; + +/** + * Priorities are used for things like ordering syntax and loading structures in a specific order. + */ +@ApiStatus.Experimental +public interface Priority extends Comparable { + + /** + * @return A base priority for other priorities to build relationships off of. + */ + @Contract("-> new") + static Priority base() { + return new PriorityImpl(); + } + + /** + * Constructs a new priority that is before priority. + * Note that this method will not make any changes to the {@link #after()} of priority. + * @param priority The priority that will be after the returned priority. + * @return A priority that is before priority. + */ + @Contract("_ -> new") + static Priority before(Priority priority) { + return new PriorityImpl(priority, true); + } + + /** + * Constructs a new priority that is after priority. + * Note that this method will not make any changes to the {@link #before()} of priority. + * @param priority The priority that will be before the returned priority. + * @return A priority that is after priority. + */ + @Contract("_ -> new") + static Priority after(Priority priority) { + return new PriorityImpl(priority, false); + } + + /** + * @return A collection of all priorities this priority is known to be after. + */ + @Unmodifiable Collection after(); + + /** + * @return A collection of all priorities this priority is known to be before. + */ + @Unmodifiable Collection before(); + +} diff --git a/src/main/java/org/skriptlang/skript/util/PriorityImpl.java b/src/main/java/org/skriptlang/skript/util/PriorityImpl.java new file mode 100644 index 00000000000..b342cf1e982 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/PriorityImpl.java @@ -0,0 +1,82 @@ +package org.skriptlang.skript.util; + +import com.google.common.collect.ImmutableSet; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +class PriorityImpl implements Priority { + + private final Set after; + + private final Set before; + + PriorityImpl() { + this.after = ImmutableSet.of(); + this.before = ImmutableSet.of(); + } + + PriorityImpl(Priority priority, boolean isBefore) { + Set after = new HashSet<>(); + Set before = new HashSet<>(); + if (isBefore) { + before.add(priority); + } else { + after.add(priority); + } + after.addAll(priority.after()); + before.addAll(priority.before()); + + this.after = ImmutableSet.copyOf(after); + this.before = ImmutableSet.copyOf(before); + } + + @Override + public int compareTo(Priority other) { + if (this == other) { + return 0; + } + + Collection ourBefore = this.before(); + Collection otherAfter = other.after(); + + // check whether this is known to be before other and whether other is known to be after this + if (ourBefore.contains(other) || otherAfter.contains(this)) { + return -1; + } + + Collection ourAfter = this.after(); + Collection otherBefore = other.before(); + + // check whether this is known to be after other and whether other is known to be before this + if (ourAfter.contains(other) || otherBefore.contains(this)) { + return 1; + } + + // check whether the set of items we are before has common elements with the set of items other is after + if (ourBefore.stream().anyMatch(otherAfter::contains)) { + return -1; + } + + // check whether the set of items we are after has common elements with the set of items other is before + if (ourAfter.stream().anyMatch(otherBefore::contains)) { + return 1; + } + + // there is no meaningful relationship, we consider ourselves the same + // however, in cases of a custom implementation, we defer to them to determine the relationship + return (other instanceof PriorityImpl) ? 0 : (other.compareTo(this) * -1); + } + + @Override + public Collection after() { + return after; + } + + @Override + public Collection before() { + return before; + } + +} diff --git a/src/main/java/org/skriptlang/skript/util/Registry.java b/src/main/java/org/skriptlang/skript/util/Registry.java new file mode 100644 index 00000000000..46e4f859785 --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/Registry.java @@ -0,0 +1,31 @@ +package org.skriptlang.skript.util; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.Collection; +import java.util.Iterator; + +/** + * A registry maintains a collection of elements. + * It is up to individual implementations as to how they may be modified. + * @param The type of elements stored in a registry. + */ +@ApiStatus.Experimental +public interface Registry extends Iterable { + + /** + * @return A collection of all elements in this registry. + */ + Collection elements(); + + /** + * By default, this is a wrapper for elements().iterator(). + * @return An iterator over all elements in this registry. + * @see Collection#iterator() + */ + @Override + default Iterator iterator() { + return elements().iterator(); + } + +} diff --git a/src/main/java/org/skriptlang/skript/util/ViewProvider.java b/src/main/java/org/skriptlang/skript/util/ViewProvider.java new file mode 100644 index 00000000000..7a9748ad1bb --- /dev/null +++ b/src/main/java/org/skriptlang/skript/util/ViewProvider.java @@ -0,0 +1,22 @@ +package org.skriptlang.skript.util; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; + +/** + * For objects that can provide an unmodifiable view of themselves. + * An unmodifiable view means that the object may only be used in a read-only manner (its values may not be changed). + * Since it is a view, it will reflect any changes made to the object it was created from. + * @param The type being viewed. + */ +@ApiStatus.Experimental +public interface ViewProvider { + + /** + * Constructs an unmodifiable view of this. + * @return An unmodifiable view of this. + */ + @Contract("-> new") + T unmodifiableView(); + +} diff --git a/src/main/resources/lang/default.lang b/src/main/resources/lang/default.lang index 96340003629..28d608aa7a9 100644 --- a/src/main/resources/lang/default.lang +++ b/src/main/resources/lang/default.lang @@ -2439,6 +2439,34 @@ item display transforms: thirdperson_lefthand: third person left handed, third person left hand, left handed in third person thirdperson_righthand: third person right handed, third person right hand, right handed in third person +# -- Villager Types/Professions -- +villager types: + snow: snow + plains: plains + jungle: jungle + taiga: taiga + desert: desert + savanna: savanna + swamp: swamp + +villager professions: + # Suffix "profession" options added to help with EntityData conflicts + leatherworker: leatherworker, leatherworker profession + mason: mason, mason profession + fletcher: fletcher, fletcher profession + weaponsmith: weaponsmith, weaponsmith profession + toolsmith: toolsmith, toolsmith profession + librarian: librarian, librarian profession + shepherd: shepherd, shepherd profession + farmer: farmer, farmer profession + cleric: cleric, cleric profession + nitwit: nitwit, nitwit profession + cartographer: cartographer, cartographer profession + armorer: armorer, armorer profession + butcher: butcher, butcher profession + none: no profession, none profession, unemployed + fisherman: fisherman, fisherman profession + # -- Change Reasons -- experience cooldown change reasons: plugin: plugin @@ -2542,6 +2570,11 @@ types: itemdisplaytransform: item display transform¦s @an experiencecooldownchangereason: experience cooldown change reason¦s @a inputkey: input key¦s @an + villagertype: villager type¦s @a + villagerprofession: villager profession¦s @a + entitysnapshot: entity snapshot¦s @an + loottable: loot table¦s @a + lootcontext: loot context¦s @a # Skript weathertype: weather type¦s @a @@ -2561,6 +2594,9 @@ types: experience.pattern: (e?xp|experience( points?)?) classinfo: type¦s @a visualeffect: visual effect¦s @a + named: named thing¦s @a + numbered: numbered thing¦s @a + containing: container¦s @a # Hooks money: money diff --git a/src/test/java/ch/njol/skript/config/ConfigHelper.java b/src/test/java/ch/njol/skript/config/ConfigHelper.java new file mode 100644 index 00000000000..b32fc18df49 --- /dev/null +++ b/src/test/java/ch/njol/skript/config/ConfigHelper.java @@ -0,0 +1,13 @@ +package ch.njol.skript.config; + +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public class ConfigHelper { + + public static @NotNull Set discoverNodes(@NotNull SectionNode node) { + return Config.discoverNodes(node); + } + +} diff --git a/src/test/java/ch/njol/skript/variables/FlatFileStorageTest.java b/src/test/java/ch/njol/skript/variables/FlatFileStorageTest.java index 3868358459c..cb9e25f89fc 100644 --- a/src/test/java/ch/njol/skript/variables/FlatFileStorageTest.java +++ b/src/test/java/ch/njol/skript/variables/FlatFileStorageTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package ch.njol.skript.variables; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/skriptlang/skript/test/junit/registration/ExprJUnitTest.java b/src/test/java/org/skriptlang/skript/test/junit/registration/ExprJUnitTest.java index 341adde13eb..e75f348b410 100644 --- a/src/test/java/org/skriptlang/skript/test/junit/registration/ExprJUnitTest.java +++ b/src/test/java/org/skriptlang/skript/test/junit/registration/ExprJUnitTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.junit.registration; import org.bukkit.event.Event; diff --git a/src/test/java/org/skriptlang/skript/test/junit/registration/package-info.java b/src/test/java/org/skriptlang/skript/test/junit/registration/package-info.java index a5287d55b8d..afb25dd1c3e 100644 --- a/src/test/java/org/skriptlang/skript/test/junit/registration/package-info.java +++ b/src/test/java/org/skriptlang/skript/test/junit/registration/package-info.java @@ -15,7 +15,8 @@ * along with Skript. If not, see . * * Copyright Peter Güttinger, SkriptLang team and contributors - * + */ +/** * Place any and all custom syntaxes relating to the JUnit testJar in here to be exclusively ran on the test runner. */ package org.skriptlang.skript.test.junit.registration; diff --git a/src/test/java/org/skriptlang/skript/test/tests/aliases/AliasesTest.java b/src/test/java/org/skriptlang/skript/test/tests/aliases/AliasesTest.java index c2ad1a61918..05c30cb3955 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/aliases/AliasesTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/aliases/AliasesTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.aliases; import org.bukkit.Color; diff --git a/src/test/java/org/skriptlang/skript/test/tests/classes/ClassesTest.java b/src/test/java/org/skriptlang/skript/test/tests/classes/ClassesTest.java index 385078a5701..edda38d818d 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/classes/ClassesTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/classes/ClassesTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.classes; import org.bukkit.GameMode; diff --git a/src/test/java/org/skriptlang/skript/test/tests/config/ConfigTest.java b/src/test/java/org/skriptlang/skript/test/tests/config/ConfigTest.java new file mode 100644 index 00000000000..19f1396b52d --- /dev/null +++ b/src/test/java/org/skriptlang/skript/test/tests/config/ConfigTest.java @@ -0,0 +1,54 @@ +package org.skriptlang.skript.test.tests.config; + +import ch.njol.skript.config.Config; +import ch.njol.skript.config.ConfigHelper; +import ch.njol.skript.config.Node; +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; + +import static org.junit.Assert.*; + +public class ConfigTest { + + @Test + public void testIsInvalid() { + Config valid = getConfig("new-config"); + Config invalid = getConfig("invalid-config"); + + assertTrue(valid.getMainNode().isValid()); + assertFalse(invalid.getMainNode().isValid()); + } + + @Test + public void testUpdateNodes() { + Config old = getConfig("old-config"); + Config newer = getConfig("new-config"); + + boolean updated = old.updateNodes(newer); + + assertTrue("updateNodes did not update any nodes", updated); + + Set newNodes = ConfigHelper.discoverNodes(newer.getMainNode()); + Set updatedNodes = ConfigHelper.discoverNodes(old.getMainNode()); + + for (Node node : newNodes) { + assertTrue("Node " + node + " was not updated", updatedNodes.contains(node)); + } + + // maintains old values + assertEquals("true", old.get("outdated value")); + assertEquals("true", old.get("a", "outdated value")); + } + + private Config getConfig(String name) { + try (InputStream resource = getClass().getResourceAsStream("/" + name + ".sk")) { + return new Config(resource, name + ".sk", false, false, ":"); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + +} diff --git a/src/test/java/org/skriptlang/skript/test/tests/config/NodeTest.java b/src/test/java/org/skriptlang/skript/test/tests/config/NodeTest.java index b0a7ff2b606..81e9148ed5d 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/config/NodeTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/config/NodeTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.config; import static org.junit.Assert.assertArrayEquals; diff --git a/src/test/java/org/skriptlang/skript/test/tests/files/FilesGenerate.java b/src/test/java/org/skriptlang/skript/test/tests/files/FilesGenerate.java index a6bcabcea71..daff16360d6 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/files/FilesGenerate.java +++ b/src/test/java/org/skriptlang/skript/test/tests/files/FilesGenerate.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.files; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/skriptlang/skript/test/tests/lang/CancelledEventsTest.java b/src/test/java/org/skriptlang/skript/test/tests/lang/CancelledEventsTest.java index 75bddb12e21..e8b1c303b27 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/lang/CancelledEventsTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/lang/CancelledEventsTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.lang; import ch.njol.skript.test.runner.SkriptJUnitTest; diff --git a/src/test/java/org/skriptlang/skript/test/tests/lang/EntryContainerTest.java b/src/test/java/org/skriptlang/skript/test/tests/lang/EntryContainerTest.java new file mode 100644 index 00000000000..433950a5145 --- /dev/null +++ b/src/test/java/org/skriptlang/skript/test/tests/lang/EntryContainerTest.java @@ -0,0 +1,11 @@ +package org.skriptlang.skript.test.tests.lang; + +import ch.njol.skript.test.runner.SkriptJUnitTest; +import org.junit.Test; + +public class EntryContainerTest extends SkriptJUnitTest { + + @Test + public void test() {} + +} diff --git a/src/test/java/org/skriptlang/skript/test/tests/localization/NounTest.java b/src/test/java/org/skriptlang/skript/test/tests/localization/NounTest.java index 0c9cd31de11..d569aec4f7d 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/localization/NounTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/localization/NounTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.localization; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/skriptlang/skript/test/tests/localization/UtilsPlurals.java b/src/test/java/org/skriptlang/skript/test/tests/localization/UtilsPlurals.java index e6ac6861c75..37dc090984a 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/localization/UtilsPlurals.java +++ b/src/test/java/org/skriptlang/skript/test/tests/localization/UtilsPlurals.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.localization; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/skriptlang/skript/test/tests/parsing/StaticParseTest.java b/src/test/java/org/skriptlang/skript/test/tests/parsing/StaticParseTest.java index b4589f63ccf..55a4ea18ec0 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/parsing/StaticParseTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/parsing/StaticParseTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.parsing; import ch.njol.skript.lang.ParseContext; diff --git a/src/test/java/org/skriptlang/skript/test/tests/regression/BlockDataNotCloned6829.java b/src/test/java/org/skriptlang/skript/test/tests/regression/BlockDataNotCloned6829.java index b621734958d..088cc3fdd78 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/regression/BlockDataNotCloned6829.java +++ b/src/test/java/org/skriptlang/skript/test/tests/regression/BlockDataNotCloned6829.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.regression; import ch.njol.skript.lang.Effect; diff --git a/src/test/java/org/skriptlang/skript/test/tests/regression/ExprPlainAliasTest.java b/src/test/java/org/skriptlang/skript/test/tests/regression/ExprPlainAliasTest.java index d5c4a3653ef..6c742aa64da 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/regression/ExprPlainAliasTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/regression/ExprPlainAliasTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.regression; import ch.njol.skript.aliases.ItemType; diff --git a/src/test/java/org/skriptlang/skript/test/tests/regression/SimpleJUnitTest.java b/src/test/java/org/skriptlang/skript/test/tests/regression/SimpleJUnitTest.java index 0f8f78b33b7..15c345d7f43 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/regression/SimpleJUnitTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/regression/SimpleJUnitTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.regression; import org.bukkit.entity.Pig; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/InventoryMoveItemEventTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/InventoryMoveItemEventTest.java index fc486687f85..e8a56fbe24d 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/InventoryMoveItemEventTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/InventoryMoveItemEventTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes; import ch.njol.skript.test.runner.SkriptJUnitTest; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffActionBarTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffActionBarTest.java index 125f22e86e8..0d7e598d967 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffActionBarTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffActionBarTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.effects; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffApplyBoneMealTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffApplyBoneMealTest.java index 5b7a5b8aa1f..3f4ed672220 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffApplyBoneMealTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffApplyBoneMealTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.effects; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffFeedTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffFeedTest.java index 1235eea38ab..54a8fb2d98f 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffFeedTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffFeedTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.effects; import ch.njol.skript.lang.Effect; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffMakeFlyTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffMakeFlyTest.java index 28497059e53..f7b047f5ef3 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffMakeFlyTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffMakeFlyTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.effects; import ch.njol.skript.lang.Effect; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffOpTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffOpTest.java index 69b237292d9..c77dd520741 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffOpTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffOpTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.effects; import ch.njol.skript.lang.Effect; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffSwingHandTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffSwingHandTest.java index 1b5da4d1a46..babfa30a0d8 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffSwingHandTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffSwingHandTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.effects; import ch.njol.skript.Skript; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/BellEventsTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/BellEventsTest.java index 07163771783..d6e17ac4f1b 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/BellEventsTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/BellEventsTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.events; import ch.njol.skript.Skript; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtFurnaceTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtFurnaceTest.java new file mode 100644 index 00000000000..45e0c678ad2 --- /dev/null +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtFurnaceTest.java @@ -0,0 +1,59 @@ +package org.skriptlang.skript.test.tests.syntaxes.events; + +import ch.njol.skript.test.runner.SkriptJUnitTest; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.event.inventory.FurnaceStartSmeltEvent; +import org.bukkit.inventory.CookingRecipe; +import org.bukkit.inventory.FurnaceRecipe; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class EvtFurnaceTest extends SkriptJUnitTest { + + private Block furnace; + private CookingRecipe recipe; + private Player easyMockPlayer; + + @Before + public void setUp() { + furnace = setBlock(Material.FURNACE); + furnace.setType(Material.FURNACE); + for (Recipe goldIngotRecipe : Bukkit.getRecipesFor(new ItemStack(Material.GOLD_INGOT))) { + if (goldIngotRecipe instanceof FurnaceRecipe furnaceRecipe) { + recipe = furnaceRecipe; + break; + } + } + easyMockPlayer = EasyMock.niceMock(Player.class); + } + + @Test + public void callEvents() { + FurnaceBurnEvent burnEvent = new FurnaceBurnEvent(furnace, new ItemStack(Material.LAVA_BUCKET), 10); + FurnaceSmeltEvent smeltEvent = new FurnaceSmeltEvent(furnace, new ItemStack(Material.RAW_IRON), new ItemStack(Material.IRON_INGOT)); + FurnaceStartSmeltEvent startEvent = new FurnaceStartSmeltEvent(furnace, new ItemStack(Material.RAW_GOLD), recipe); + FurnaceExtractEvent extractEvent = new FurnaceExtractEvent(easyMockPlayer, furnace, Material.COPPER_INGOT, 10, 20); + + Bukkit.getPluginManager().callEvent(burnEvent); + Bukkit.getPluginManager().callEvent(smeltEvent); + Bukkit.getPluginManager().callEvent(startEvent); + Bukkit.getPluginManager().callEvent(extractEvent); + } + + @After + public void cleanUp() { + furnace.setType(Material.AIR); + } + +} diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtGrowTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtGrowTest.java index 44cb566c33f..c6298498ff4 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtGrowTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtGrowTest.java @@ -1,24 +1,5 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.events; -import ch.njol.skript.Skript; import ch.njol.skript.test.runner.SkriptJUnitTest; import org.bukkit.Material; import org.bukkit.block.Block; @@ -31,7 +12,6 @@ public class EvtGrowTest extends SkriptJUnitTest { private Block plant, birch; - private static final boolean canRun = Skript.methodExists(Block.class, "applyBoneMeal", BlockFace.class); static { setShutdownDelay(1); @@ -39,8 +19,9 @@ public class EvtGrowTest extends SkriptJUnitTest { @Before public void setBlocks() { - plant = setBlock(Material.WHEAT); - plant.getRelative(0,-1,0).setType(Material.FARMLAND); + Block farmland = setBlock(Material.FARMLAND); + farmland.getRelative(0, 1, 0).setType(Material.WHEAT); + plant = farmland.getRelative(0, 1, 0); birch = plant.getRelative(10,0,0); birch.getRelative(0,-1,0).setType(Material.DIRT); birch.setType(Material.BIRCH_SAPLING); @@ -48,20 +29,18 @@ public void setBlocks() { @Test public void testGrow() { - if (canRun) { - int maxIterations = 100; - int iterations = 0; - while (((Ageable) plant.getBlockData()).getAge() != ((Ageable) plant.getBlockData()).getMaximumAge()) { - plant.applyBoneMeal(BlockFace.UP); - if (iterations++ > maxIterations) - return; - } - iterations = 0; - while (birch.getType() == Material.BIRCH_SAPLING) { - birch.applyBoneMeal(BlockFace.UP); - if (iterations++ > maxIterations) - return; - } + int maxIterations = 100; + int iterations = 0; + while (plant.getBlockData() instanceof Ageable ageable && ageable.getAge() != ageable.getMaximumAge()) { + plant.applyBoneMeal(BlockFace.UP); + if (iterations++ > maxIterations) + break; + } + iterations = 0; + while (birch.getType() == Material.BIRCH_SAPLING) { + birch.applyBoneMeal(BlockFace.UP); + if (iterations++ > maxIterations) + break; } } diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtPiglinBarterTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtPiglinBarterTest.java index 275bfbd1b72..9752d3f06a4 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtPiglinBarterTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/EvtPiglinBarterTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.events; import ch.njol.skript.Skript; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/PlayerElytraBoostEventTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/PlayerElytraBoostEventTest.java new file mode 100644 index 00000000000..75855937cc6 --- /dev/null +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/events/PlayerElytraBoostEventTest.java @@ -0,0 +1,72 @@ +package org.skriptlang.skript.test.tests.syntaxes.events; + +import ch.njol.skript.test.runner.SkriptJUnitTest; +import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.lang.reflect.Constructor; + +public class PlayerElytraBoostEventTest extends SkriptJUnitTest { + + private Player player; + private Firework firework; + + @Before + public void setUp() { + player = EasyMock.niceMock(Player.class); + EntityType entityType = EntityType.valueOf("FIREWORK"); + if (entityType == null) { + entityType = EntityType.valueOf("FIREWORK_ROCKET"); + } + assert entityType != null; + firework = (Firework) getTestWorld().spawnEntity(getTestLocation(), entityType); + firework.setTicksToDetonate(9999999); + } + + @Test + public void test() { + Constructor constructor = null; + boolean newerConstructor = false; + try { + constructor = PlayerElytraBoostEvent.class.getConstructor(Player.class, ItemStack.class, Firework.class, EquipmentSlot.class); + newerConstructor = true; + } catch (Exception ignored) { + try { + constructor = PlayerElytraBoostEvent.class.getConstructor(Player.class, ItemStack.class, Firework.class); + } catch (NoSuchMethodException e) { + throw new IllegalStateException("No valid constructor for 'PlayerElytraBoostEvent'"); + } + } + + try { + Event event; + if (newerConstructor) { + event = (Event) constructor.newInstance(player, new ItemStack(Material.FIREWORK_ROCKET), firework, EquipmentSlot.HAND); + } else { + event = (Event) constructor.newInstance(player, new ItemStack(Material.FIREWORK_ROCKET), firework); + } + + Bukkit.getPluginManager().callEvent(event); + } catch (Exception e) { + throw new RuntimeException("Unable to construct event."); + } + } + + @After + public void cleanUp() { + if (firework != null) + firework.remove(); + } + +} diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprDropsTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprDropsTest.java index f9f9c372176..5a28dae81d6 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprDropsTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprDropsTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.expressions; import ch.njol.skript.test.runner.SkriptJUnitTest; diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprLootContextLooterTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprLootContextLooterTest.java new file mode 100644 index 00000000000..431e307d3b8 --- /dev/null +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprLootContextLooterTest.java @@ -0,0 +1,27 @@ +package org.skriptlang.skript.test.tests.syntaxes.expressions; + +import ch.njol.skript.test.runner.SkriptJUnitTest; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerJoinEvent; +import org.easymock.EasyMock; +import org.junit.Test; + +public class ExprLootContextLooterTest extends SkriptJUnitTest { + + static { + setShutdownDelay(1); + } + + @Test + public void test() { + Player player = EasyMock.niceMock(Player.class); + Location location = new Location(Bukkit.getWorld("world"), 0, 0, 0); + + EasyMock.expect(player.getLocation()).andReturn(location); + EasyMock.replay(player); + + Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(player, "ok")); + } +} diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprMessageTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprMessageTest.java index 1b0cbefa703..7c63f63b836 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprMessageTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/expressions/ExprMessageTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.syntaxes.expressions; import ch.njol.skript.test.runner.SkriptJUnitTest; diff --git a/src/test/java/org/skriptlang/skript/test/tests/utils/ClassInfoReferenceTest.java b/src/test/java/org/skriptlang/skript/test/tests/utils/ClassInfoReferenceTest.java index a9540240e23..c2cc77192c0 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/utils/ClassInfoReferenceTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/utils/ClassInfoReferenceTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.utils; import ch.njol.skript.classes.ClassInfo; diff --git a/src/test/java/org/skriptlang/skript/test/tests/utils/UtilsTest.java b/src/test/java/org/skriptlang/skript/test/tests/utils/UtilsTest.java index 592ea5c9fa8..1637f67f875 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/utils/UtilsTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/utils/UtilsTest.java @@ -1,21 +1,3 @@ -/** - * This file is part of Skript. - * - * Skript is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Skript is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Skript. If not, see . - * - * Copyright Peter Güttinger, SkriptLang team and contributors - */ package org.skriptlang.skript.test.tests.utils; import static org.junit.Assert.assertEquals; diff --git a/src/test/resources/invalid-config.sk b/src/test/resources/invalid-config.sk new file mode 100644 index 00000000000..6faf34dd4c5 --- /dev/null +++ b/src/test/resources/invalid-config.sk @@ -0,0 +1,20 @@ +# Comment a +a: + b: # Comment b + c: true # Comment c + d: false # <<< Invalid + e: true + f: true + # Comment f + # Comment f' + + g: true + + # Comment g + +# Comment a' +h: false +i: true # Comment i + +x.z: + y: true diff --git a/src/test/resources/new-config.sk b/src/test/resources/new-config.sk new file mode 100644 index 00000000000..3888fc454ec --- /dev/null +++ b/src/test/resources/new-config.sk @@ -0,0 +1,20 @@ +# Comment a +a: + b: # Comment b + c: true # Comment c + d: false + e: true + f: true + # Comment f + # Comment f' + + g: true + + # Comment g + +# Comment a' +h: false +i: true # Comment i + +x.z: + y: true diff --git a/src/test/resources/old-config.sk b/src/test/resources/old-config.sk new file mode 100644 index 00000000000..8c0fd57425e --- /dev/null +++ b/src/test/resources/old-config.sk @@ -0,0 +1,19 @@ +# Comment a +a: + b: # Comment b + c: true + e: true + f: true + # Comment f + # Comment f' + + outdated value: true + +# Comment a' +h: false +i: true # Comment i + +outdated value: true + +x.z: + y: true diff --git a/src/test/skript/junit/EntryContainerTest.sk b/src/test/skript/junit/EntryContainerTest.sk new file mode 100644 index 00000000000..13376089928 --- /dev/null +++ b/src/test/skript/junit/EntryContainerTest.sk @@ -0,0 +1,9 @@ +options: + test: "org.skriptlang.skript.test.tests.syntaxes.events.EntryContainerTest" + +test "EntryContainerTest" when running JUnit: + ensure junit test {@test} completes "has entry" + +test entry container: + has entry: + complete objective "has entry" for {@test} diff --git a/src/test/skript/junit/EvtFurnaceTest.sk b/src/test/skript/junit/EvtFurnaceTest.sk new file mode 100644 index 00000000000..f65a04135ea --- /dev/null +++ b/src/test/skript/junit/EvtFurnaceTest.sk @@ -0,0 +1,42 @@ +options: + EvtFurnaceTest: "org.skriptlang.skript.test.tests.syntaxes.events.EvtFurnaceTest" + +on load: + set {_tests::1} to "smelt event" + set {_tests::2} to "smelt - got smelted item" + set {_tests::3} to "start smelt event" + set {_tests::4} to "start smelt - got smelting item" + set {_tests::5} to "fuel burn event" + set {_tests::6} to "fuel burn - got burned fuel item" + set {_tests::7} to "extract event" + set {_tests::8} to "extract - got extracted item" + set {_tests::9} to "extract - got player" + + ensure junit test {@EvtFurnaceTest} completes {_tests::*} + +on smelt: + junit test is {@EvtFurnaceTest} + complete objective "smelt event" for junit test {@EvtFurnaceTest} + broadcast "%smelted item%" + if smelted item is an iron ingot: + complete objective "smelt - got smelted item" for junit test {@EvtFurnaceTest} + +on start smelt: + junit test is {@EvtFurnaceTest} + complete objective "start smelt event" for junit test {@EvtFurnaceTest} + if smelting item is a raw gold: + complete objective "start smelt - got smelting item" for junit test {@EvtFurnaceTest} + +on fuel burn: + junit test is {@EvtFurnaceTest} + complete objective "fuel burn event" for junit test {@EvtFurnaceTest} + if burned fuel is a lava bucket: + complete objective "fuel burn - got burned fuel item" for junit test {@EvtFurnaceTest} + +on furnace extract: + junit test is {@EvtFurnaceTest} + complete objective "extract event" for junit test {@EvtFurnaceTest} + if extracted item is a copper ingot: + complete objective "extract - got extracted item" for junit test {@EvtFurnaceTest} + if event-player is set: + complete objective "extract - got player" for junit test {@EvtFurnaceTest} diff --git a/src/test/skript/junit/EvtGrow.sk b/src/test/skript/junit/EvtGrow.sk index 080dfd819b9..7873455d4be 100644 --- a/src/test/skript/junit/EvtGrow.sk +++ b/src/test/skript/junit/EvtGrow.sk @@ -1,70 +1,59 @@ -on script load: - # prior to 1.18, applyBoneMeal either did not exist or did not fire events - # so we need to complete the objectives manually to avoid the tests failing - if running below minecraft "1.18": - complete objective "grow of wheat" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow from wheat" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow to wheat" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of wheat (blockdata)" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow from wheat (blockdata)" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow to wheat (blockdata)" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of birch tree" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of birch sapling" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow from birch sapling" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow to birch tree" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" +options: + test: "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" +on script load: # itemtype - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow of wheat" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow from wheat" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow to wheat" + ensure junit test {@test} completes "grow of wheat" + ensure junit test {@test} completes "grow from wheat" + ensure junit test {@test} completes "grow to wheat" # blockdata - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow of wheat (blockdata)" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow from wheat (blockdata)" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow to wheat (blockdata)" + ensure junit test {@test} completes "grow of wheat (blockdata)" + ensure junit test {@test} completes "grow from wheat (blockdata)" + ensure junit test {@test} completes "grow to wheat (blockdata)" # structures - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow of birch tree" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow of birch sapling" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow from birch sapling" - ensure junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" completes "grow to birch tree" + ensure junit test {@test} completes "grow of birch tree" + ensure junit test {@test} completes "grow of birch sapling" + ensure junit test {@test} completes "grow from birch sapling" + ensure junit test {@test} completes "grow to birch tree" on grow of wheat: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of wheat" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow of wheat" for junit test {@test} on grow of wheat[age=0]: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of wheat (blockdata)" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow of wheat (blockdata)" for junit test {@test} on grow from wheat: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow from wheat" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow from wheat" for junit test {@test} on grow from wheat[age=0]: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow from wheat (blockdata)" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow from wheat (blockdata)" for junit test {@test} on grow to wheat: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow to wheat" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow to wheat" for junit test {@test} on grow to wheat[age=7]: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow to wheat (blockdata)" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow to wheat (blockdata)" for junit test {@test} on grow of birch tree: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of birch tree" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow of birch tree" for junit test {@test} on grow of birch sapling: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow of birch sapling" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow of birch sapling" for junit test {@test} on grow from birch sapling: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow from birch sapling" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow from birch sapling" for junit test {@test} on grow to birch tree: - junit test is "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" - complete objective "grow to birch tree" for junit test "org.skriptlang.skript.test.tests.syntaxes.events.EvtGrowTest" + junit test is {@test} + complete objective "grow to birch tree" for junit test {@test} diff --git a/src/test/skript/junit/ExprLootContextLooter.sk b/src/test/skript/junit/ExprLootContextLooter.sk new file mode 100644 index 00000000000..31364456b06 --- /dev/null +++ b/src/test/skript/junit/ExprLootContextLooter.sk @@ -0,0 +1,22 @@ +options: + test: "org.skriptlang.skript.test.tests.syntaxes.expressions.ExprLootContextLooterTest" + +test "ExprLootContextKillerJUnit" when running JUnit: + set {_tests::1} to "set killer" + set {_tests::2} to "clear killer" + ensure junit test {@test} completes {_tests::*} + +on join: + junit test is {@test} + + set {_player} to player + set {_context} to a loot context at player's location: + set looter to {_player} + + if looter is {_player}: + complete objective "set killer" for {@test} + + reset looter + + if looter is not set: + complete objective "clear killer" for {@test} diff --git a/src/test/skript/junit/PlayerElytraBoostEventTest.sk b/src/test/skript/junit/PlayerElytraBoostEventTest.sk new file mode 100644 index 00000000000..1a4384e8f33 --- /dev/null +++ b/src/test/skript/junit/PlayerElytraBoostEventTest.sk @@ -0,0 +1,16 @@ +options: + test: "org.skriptlang.skript.test.tests.syntaxes.events.PlayerElytraBoostEventTest" + +test "PlayerElytraBoosEventTest" when running JUnit: + set {_tests::*} to "boost event called", "boost event - firework item", "boost event - player" and "boost event - firework entity" + ensure junit test {@test} completes {_tests::*} + +on elytra boost: + junit test is {@test} + complete objective "boost event called" for {@test} + if event-item is a firework rocket: + complete objective "boost event - firework item" for {@test} + if event-entity is a firework: + complete objective "boost event - firework entity" for {@test} + if event-player is set: + complete objective "boost event - player" for {@test} diff --git a/src/test/skript/tests/misc/supported events.sk b/src/test/skript/tests/misc/supported events.sk new file mode 100644 index 00000000000..f0cfc2f8a16 --- /dev/null +++ b/src/test/skript/tests/misc/supported events.sk @@ -0,0 +1,5 @@ +test "supported events": + parse: + set {_x} to the exploded blocks + + assert last parse logs contain "'the exploded blocks' can only be used in the entity explode event" with "supported events message did not get sent correctly" diff --git a/src/test/skript/tests/misc/unicode.sk b/src/test/skript/tests/misc/unicode.sk new file mode 100644 index 00000000000..3a6e9ba7816 --- /dev/null +++ b/src/test/skript/tests/misc/unicode.sk @@ -0,0 +1,6 @@ +test "unicode": + assert "" is "§" with "single symbol did not get replaced" + assert "" is "§" with "single short symbol did not get replaced" + + assert "aB" is "a🐛B" with "symbol did not get replaced" + assert "aB" is "a🐛B" with "short symbol did not get replaced" diff --git a/src/test/skript/tests/syntaxes/conditions/CondHasLootTable.sk b/src/test/skript/tests/syntaxes/conditions/CondHasLootTable.sk new file mode 100644 index 00000000000..b16cef8ef84 --- /dev/null +++ b/src/test/skript/tests/syntaxes/conditions/CondHasLootTable.sk @@ -0,0 +1,30 @@ +test "loot table condition": + spawn a pig at test-location + set {_pig} to last spawned pig + + assert {_pig} has loot table with "default has loot table failed" + + set loot table of {_pig} to loot table "minecraft:entities/cow" + assert {_pig} has loot table with "simple has loot table failed" + + set loot table of {_pig} to "bleh blah bluh" parsed as loot table + assert {_pig} has loot table with "pig doesn't have loot table after setting invalid loot table" + + delete entity within {_pig} + + set {_pastBlock} to block data of test-block + + set test-block to chest + + assert test-block doesn't have loot table with "has loot table without setting it" + + set loot table of test-block to loot table "minecraft:chests/simple_dungeon" + assert test-block has loot table with "simple has loot table failed" + + clear loot table of test-block + assert test-block doesn't have a loot table with "block still has loot table after clearing loot table" + + set loot table of test-block to "bleh blah bluh" parsed as loot table + assert test-block doesn't have a loot table with "block still has loot table after setting invalid loot table" + + set test-block to {_pastBlock} diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsLootable.sk b/src/test/skript/tests/syntaxes/conditions/CondIsLootable.sk new file mode 100644 index 00000000000..2fe22856d58 --- /dev/null +++ b/src/test/skript/tests/syntaxes/conditions/CondIsLootable.sk @@ -0,0 +1,17 @@ +test "is lootable": + spawn a pig at test-location + set {_pig} to last spawned pig + + assert {_pig} is lootable with "is lootable entity failed" + + delete entity within {_pig} + + set {_pastBlock} to block data of test-block + + set test-block to wool block + assert test-block is not lootable with "is not lootable failed" + + set test-block to chest + assert test-block is lootable with "is lootable chest failed" + + set test-block to {_pastBlock} diff --git a/src/test/skript/tests/syntaxes/effects/EffBlockUpdate.sk b/src/test/skript/tests/syntaxes/effects/EffBlockUpdate.sk new file mode 100644 index 00000000000..e0404e3a5f8 --- /dev/null +++ b/src/test/skript/tests/syntaxes/effects/EffBlockUpdate.sk @@ -0,0 +1,8 @@ +test "block update": + set {_loc} to spawn of world "world" ~ vector(10,10,10) + set {_blocks::*} to blocks in radius 2 of block at {_loc} + + update blocks at {_blocks::*} as sand without physics updates + assert blocks at {_blocks::*} is sand with "1 or more blocks did not update with or without physics" + update blocks at {_blocks::*} as air without physics updates + assert blocks at {_blocks::*} is air with "1 or more blocks did not update to air" diff --git a/src/test/skript/tests/syntaxes/effects/EffHealth.sk b/src/test/skript/tests/syntaxes/effects/EffHealth.sk index 719522ed0a6..ca417b36eec 100644 --- a/src/test/skript/tests/syntaxes/effects/EffHealth.sk +++ b/src/test/skript/tests/syntaxes/effects/EffHealth.sk @@ -7,9 +7,10 @@ test "health effect": repair {_i} by 49 assert {_i}'s damage value is 1 with "repair item failed" - spawn cow at location(0, 64, 0, world "world") + spawn cow at test-location set {_m} to last spawned cow assert health of {_m} is 5 with "default cow health failed" + damage {_m} by 3 assert health of {_m} is 2 with "damage cow failed" heal {_m} by 1 @@ -18,4 +19,13 @@ test "health effect": assert health of {_m} is 3.5 with "heal cow failed" heal {_m} by 99 assert health of {_m} is 5 with "heal cow failed" + delete the entity in {_m} + + parse if running minecraft "1.20.4": + spawn cow at test-location + set {_m} to last spawned cow + assert health of {_m} is 5 with "default cow (with cause) health failed" + damage {_m} by 2 hearts with damage cause fall + assert health of {_m} is 3 with "damage cow (with cause) failed" + clear all entities diff --git a/src/test/skript/tests/syntaxes/expressions/ExprAmount.sk b/src/test/skript/tests/syntaxes/expressions/ExprAmount.sk new file mode 100644 index 00000000000..d4cc336b031 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprAmount.sk @@ -0,0 +1,12 @@ +test "amount of objects": + set {_objects::*} to (1 and 2) + set {_amount} to amount of {_objects::*} + assert {_amount} is 2 with "was wrong" + set {_objects::*} to ("hello", "there" and 1) + set {_amount} to amount of {_objects::*} + assert {_amount} is 3 with "was wrong" + +test "amount of items": + assert amount of (3 of stone) is 3 with "was wrong" + set {_item} to 3 of stone + assert amount of {_item} is 3 with "was wrong" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprEntitySnapshot.sk b/src/test/skript/tests/syntaxes/expressions/ExprEntitySnapshot.sk new file mode 100644 index 00000000000..ba444ee2ae9 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprEntitySnapshot.sk @@ -0,0 +1,16 @@ +test "entity snapshots" when running minecraft "1.20.2": + spawn a pig at test-location: + set the max health of entity to 20 + set the health of entity to 20 + set {_snapshot} to entity snapshot of entity + clear entity + assert {_snapshot} is an entity snapshot with "Get entity snapshot is not an entity snapshot" + spawn {_snapshot} at test-location: + assert the max health of entity is 20 with "Max health did not stick to the spawned entity" + assert the health of entity is 20 with "Health did not stick to the spawned entity" + clear entity + + set {_item} to a zombie spawn egg + set the spawn egg entity of {_item} to {_snapshot} + if running minecraft "1.20.5": + assert the spawn egg entity of {_item} is {_snapshot} with "Spawn egg entity is not stored snapshot" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprFurnaceSlot.sk b/src/test/skript/tests/syntaxes/expressions/ExprFurnace.sk similarity index 64% rename from src/test/skript/tests/syntaxes/expressions/ExprFurnaceSlot.sk rename to src/test/skript/tests/syntaxes/expressions/ExprFurnace.sk index b7bf3a27e1a..111dbfcd714 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprFurnaceSlot.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprFurnace.sk @@ -29,3 +29,26 @@ test "furnace slot": # cleanup set test-block to air + +test "furnace expressions": + set {_loc} to location(0, 0, 0, world) + set block at {_loc} to furnace + set block at location(0, 0, 0, world) to furnace + set {_furnace} to block at location(0, 0, 0, world) + + set the cook time of {_furnace} to 10 seconds + assert the cook time of {_furnace} is 10 seconds with "Set furnace cook time to 10" + clear the cook time of {_furnace} + assert the cook time of {_furnace} is 0 seconds with "Clear furnace cook time" + + set the total cook time of {_furnace} to 20 seconds + assert the total cook time of {_furnace} is 20 seconds with "Set furnace total cook time to 20" + clear the total cook time of {_furnace} + assert the total cook time of {_furnace} is 0 seconds with "Clear furnace total cook time" + + set the fuel burn time of {_furnace} to 50 seconds + assert the fuel burn time of {_furnace} is 50 seconds with "Set furnace fuel burn time to 50" + clear the fuel burn time of {_furnace} + assert the fuel burn time of {_furnace} is 0 seconds with "Clear furnace fuel burn time" + + set block at location(0, 0, 0, world) to air diff --git a/src/test/skript/tests/syntaxes/expressions/ExprItemWithEnchantmentGlint.sk b/src/test/skript/tests/syntaxes/expressions/ExprItemWithEnchantmentGlint.sk new file mode 100644 index 00000000000..ec557cd4186 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprItemWithEnchantmentGlint.sk @@ -0,0 +1,43 @@ +test "item enchantment glint" when running minecraft "1.20.5": + # Glint + set {_item} to diamond with enchantment glint + assert {_item} has enchantment glint override with "Item expected to have enchantment glint override #1" + assert {_item} is forced to glint with "Item expected to be forced to glint #1" + delete {_item} + + set {_item} to diamond + make {_item} glint + assert {_item} has enchantment glint override with "Item expected to have enchantment glint override #2" + assert {_item} is forced to glint with "Item expected to be forced to glint #2" + delete {_item} + + set {_item} to diamond without enchantment glint + assert {_item} has enchantment glint override with "Item expected to have enchantment glint override #3" + assert {_item} is forced to not glint with "Item expected to be forced to not glint #1" + delete {_item} + + # Not Glint + set {_item} to diamond + make {_item} not glint + assert {_item} has enchantment glint override with "Item expected to have enchantment glint override #4" + assert {_item} is forced to not glint with "Item expected to be forced to not glint #2" + delete {_item} + + # Without Glint Enforcement + set {_item} to diamond + assert {_item} does not have enchantment glint override with "Item expected to not have enchantment glint override #1" + + set {_item} to {_item} with enchantment glint + clear enchantment glint override of {_item} + assert {_item} does not have enchantment glint override with "Item expected to not have enchantment glint override #2" + +test "item enchantment glint - edge cases" when running minecraft "1.20.5": + assert {_null} is forced to glint to fail with "Condition 'item is forced to glint' expected to fail with non itemtypes #1" + assert {_null} has enchantment glint override to fail with "Condition 'item has enchantment glint override' expected to fail with non itemtypes #1" + assert any wool does not have enchantment glint override with "Condition 'does not have enchantment glint override' failed with plural itemtype aliases" + assert diamond with enchantment glint = diamond with enchantment glint with "Item with enchantment glint comparison failed #1" + assert diamond with enchantment glint != diamond without enchantment glint with "Item with enchantment glint comparison failed #2" + assert diamond != diamond with enchantment glint with "Item with enchantment glint comparison failed #3" + assert diamond with enchantment glint and stone with enchantment glint is forced to glint with "Both items expected to be forced to glint #1" + assert diamond without enchantment glint and stone without enchantment glint is forced to not glint with "Both items expected to be forced to glint #2" + assert diamond with enchantment glint and stone without enchantment glint have enchantment glint override with "Both items expected to have enchantment glint override" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLootContext.sk b/src/test/skript/tests/syntaxes/expressions/ExprLootContext.sk new file mode 100644 index 00000000000..e71e7828484 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprLootContext.sk @@ -0,0 +1,43 @@ +test "loot context": + + set {_context} to a loot context at test-location + assert loot location of {_context} is test-location with "loot context location failed" + + spawn a pig at test-location + set {_pig} to last spawned pig + + set {_context} to a loot context at test-location: + assert loot context is set with "loot context not set" + set looted entity to {_pig} + set loot luck value to 10 + set loot location to location(1,1,1, world "world") + assert loot location is location(1,1,1, world "world") with "loot context location set failed" + + assert looted entity of {_context} is {_pig} with "loot context entity failed" + assert loot luck value of {_context} is 10 with "simple loot context luck value failed" + + delete entity within {_pig} + + set {_context} to a loot context at test-location: + set loot luck value to -1 + assert the loot luck of {_context} is -1 with "negative loot luck set failed" + + set {_context} to a loot context at test-location: + set loot luck value to 2 + assert the loot luck of {_context} is 2 with "existing loot luck set failed" + + set {_context} to a loot context at test-location: + set loot luck value to 3.3 + assert the loot luck of {_context} is 3.3 with "decimal loot luck set failed" + + set {_context} to a loot context at test-location: + set loot luck value to 3.999 + assert the loot luck of {_context} is 3.999 with "close decimal loot luck set failed" + + set {_context} to a loot context at test-location: + set loot luck value to -3.3 + assert the loot luck of {_context} is -3.3 with "negative decimal loot luck set failed" + + set {_context} to a loot context at test-location: + set loot luck value to -3.999 + assert the loot luck of {_context} is -3.999 with "negative close decimal loot luck set failed" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLootItems.sk b/src/test/skript/tests/syntaxes/expressions/ExprLootItems.sk new file mode 100644 index 00000000000..886f467c266 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprLootItems.sk @@ -0,0 +1,12 @@ +test "loot items": + + set {_context} to a loot context at test-location + set {_items::*} to loot of loot table "minecraft:chests/simple_dungeon" with {_context} + + assert {_items::*} is set with "loot items not set" + + set {_items::*} to loot of loot table "minecraft:entities/pig" with {_context} + assert {_items::*} is not set with "loot items set" + + set {_items::*} to loot of loot table "minecraft:chests/simple_dungeon" + assert {_items::*} is set with "loot items with chest loot table without context not set" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLootTable.sk b/src/test/skript/tests/syntaxes/expressions/ExprLootTable.sk new file mode 100644 index 00000000000..d1d3c9a01fd --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprLootTable.sk @@ -0,0 +1,23 @@ +test "loot table": + + spawn a pig at test-location + set {_pig} to last spawned pig + + assert loot table of {_pig} is loot table "minecraft:entities/pig" with "entity loot table is not 'minecraft:entities/pig'" + + delete entity within {_pig} + + set {_pastBlock} to block data of test-block + + set test-block to chest + + set loot table of test-block to loot table "minecraft:chests/simple_dungeon" + assert loot table of test-block is loot table "minecraft:chests/simple_dungeon" with "block loot table is not 'minecraft:chests/simple_dungeon'" + + set loot table of test-block to loot table "minecraft:entities/pig" + assert loot table of test-block is loot table "minecraft:entities/pig" with "block loot table is not 'minecraft:entities/pig'" + + set loot table of test-block to "invalidloottable" parsed as loot table + assert loot table of test-block is not set with "block loot table is set" + + set test-block to {_pastBlock} diff --git a/src/test/skript/tests/syntaxes/expressions/ExprLootTableSeed.sk b/src/test/skript/tests/syntaxes/expressions/ExprLootTableSeed.sk new file mode 100644 index 00000000000..639c7adf792 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprLootTableSeed.sk @@ -0,0 +1,48 @@ +test "loot table seed": + + spawn a pig at test-location + set {_pig} to last spawned pig + + assert the loot seed of {_pig} is 0 with "default entity loot seed failed" + set loot seed of {_pig} to 5 + assert the loot seed of {_pig} is 5 with "simple entity loot seed set failed" + set loot seed of {_pig} to -1 + assert the loot seed of {_pig} is -1 with "negative entity loot seed set failed" + set loot seed of {_pig} to 2 + assert the loot seed of {_pig} is 2 with "existing entity loot seed set failed" + set loot seed of {_pig} to 3.3 + assert the loot seed of {_pig} is 3 with "decimal entity loot seed set failed" + set loot seed of {_pig} to 3.999 + assert the loot seed of {_pig} is 3 with "close entity decimal loot seed set failed" + set loot seed of {_pig} to NaN value + assert the loot seed of {_pig} is 0 with "NaN value entity loot seed set failed" + set loot seed of {_pig} to infinity value + assert the loot seed of {_pig} is 9223372036854775807 with "infinity value entity loot seed set failed" + + delete entity within {_pig} + + set {_pastBlock} to block data of test-block + + set test-block to chest + + assert the loot seed of test-block is 0 with "default block loot seed before setting loot table failed" + + set loot table of test-block to loot table "minecraft:chests/simple_dungeon" + + assert the loot seed of test-block is 0 with "default block loot after setting loot table seed failed" + set loot seed of test-block to 5 + assert the loot seed of test-block is 5 with "simple block loot seed set failed" + set loot seed of test-block to -1 + assert the loot seed of test-block is -1 with "negative block loot seed set failed" + set loot seed of test-block to 2 + assert the loot seed of test-block is 2 with "existing block loot seed set failed" + set loot seed of test-block to 3.3 + assert the loot seed of test-block is 3 with "decimal block loot seed set failed" + set loot seed of test-block to 3.999 + assert the loot seed of test-block is 3 with "close block decimal loot seed set failed" + set loot seed of test-block to NaN value + assert the loot seed of test-block is 0 with "NaN value block loot seed set failed" + set loot seed of test-block to infinity value + assert the loot seed of test-block is 9223372036854775807 with "infinity value block loot seed set failed" + + set test-block to {_pastBlock} diff --git a/src/test/skript/tests/syntaxes/expressions/ExprName.sk b/src/test/skript/tests/syntaxes/expressions/ExprName.sk new file mode 100644 index 00000000000..142e727de34 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprName.sk @@ -0,0 +1,26 @@ +test "name of world": + set {_thing} to the world "world" + assert name of {_thing} is "world" with "name was wrong" + set the name of {_thing} to "blob" + assert name of {_thing} is "world" with "world name changed" + +test "name of entity": + set {_before} to 5 + spawn a pig at spawn of "world": + assert event-entity is a pig with "entity not a pig" + set {_test} to event-entity + set event-entity's name to "foo" + assert {_test} is set with "entity not set" + assert {_test} is a pig with "entity variable not a pig" + assert event-entity's name is "foo" with "name didn't change" + assert {_test} exists with "entity didn't carry out" + assert {_test}'s name is "foo" with "name didn't carry out" + set {_test}'s name to "bar" + assert {_test}'s name is "bar" with "name didn't change" + delete the last spawned pig + +test "name of item": + set {_thing} to 3 of stone + assert name of {_thing} does not exist with "name was set" + set the name of {_thing} to "blob" + assert name of {_thing} is "blob" with "item name didn't change" diff --git a/src/test/skript/tests/syntaxes/expressions/ExprVillagerLevel.sk b/src/test/skript/tests/syntaxes/expressions/ExprVillagerLevel.sk new file mode 100644 index 00000000000..fd1060c0c5d --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprVillagerLevel.sk @@ -0,0 +1,33 @@ +test "villager level expression": + spawn a villager at event-location: + set {_e} to entity + + # Level + assert villager level of {_e} = 1 with "Villager should start out with a level of 1" + set villager level of {_e} to 2 + assert villager level of {_e} = 2 with "Villager level should now be 2" + add 2 to villager level of {_e} + assert villager level of {_e} = 4 with "Villager level should now be 4" + add 5 to villager level of {_e} + assert villager level of {_e} = 5 with "Villager level is capped at 5, and should now be 5" + remove 2 from villager level of {_e} + assert villager level of {_e} = 3 with "Villager level should be 3 now" + reset villager level of {_e} + assert villager level of {_e} = 1 with "Villager level should reset back to 1" + + # Experience + set villager experience of {_e} to 0 + assert villager experience of {_e} = 0 with "Villager experience should be 0" + set villager experience of {_e} to 100 + assert villager experience of {_e} = 100 with "Villager experience should be 100 after setting" + remove 1000 from villager experience of {_e} + assert villager experience of {_e} = 0 with "Villager experience should be 0 after removing" + add 100 to villager experience of {_e} + assert villager experience of {_e} = 100 with "Villager experience should be 100 after adding" + remove 20 from villager experience of {_e} + assert villager experience of {_e} = 80 with "Villager experience should be 80 after removing" + reset villager experience of {_e} + assert villager experience of {_e} = 0 with "Villager experience should have been reset to 0" + + # Thank you for your service + delete entity within {_e} diff --git a/src/test/skript/tests/syntaxes/expressions/ExprVillagerProfession.sk b/src/test/skript/tests/syntaxes/expressions/ExprVillagerProfession.sk new file mode 100644 index 00000000000..71e2250d6fe --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprVillagerProfession.sk @@ -0,0 +1,14 @@ +test "villager profession expression": + spawn a librarian at event-location: + # Make sure he keeps his job + set villager level of entity to 2 + set {_e} to entity + + assert villager profession of {_e} = librarian profession with "The villager should have spawned as a librarian" + set villager profession of {_e} to nitwit profession + assert villager profession of {_e} = nitwit profession with "The villager should now be a nitwit" + delete villager profession of {_e} + assert villager profession of {_e} = no profession with "The villager should now have no profession" + + # Thank you for your service + delete entity within {_e} diff --git a/src/test/skript/tests/syntaxes/expressions/ExprVillagerType.sk b/src/test/skript/tests/syntaxes/expressions/ExprVillagerType.sk new file mode 100644 index 00000000000..ebae093a5db --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprVillagerType.sk @@ -0,0 +1,11 @@ +test "villager type expression": + spawn a villager at event-location: + set {_e} to event-entity + + set villager type of {_e} to plains + assert villager type of {_e} = plains with "The villager should now have the type plains" + set villager type of {_e} to desert + assert villager type of {_e} = desert with "The villager should now have the type desert" + + # Thank you for your service + delete entity within {_e} diff --git a/src/test/skript/tests/syntaxes/sections/EffSecShoot.sk b/src/test/skript/tests/syntaxes/sections/EffSecShoot.sk new file mode 100644 index 00000000000..5ffc75ea374 --- /dev/null +++ b/src/test/skript/tests/syntaxes/sections/EffSecShoot.sk @@ -0,0 +1,34 @@ +test "EffSecShoot": + set {_loc} to spawn of world "world" + spawn pig at {_loc}: + set ai of entity to false + set {_shooter} to entity + + shoot a pig from {_shooter} + assert last shot entity is a pig with "Last shot entity is not a pig" + clear last shot entity + + spawn cow at {_loc}: + set ai of entity to false + set {_shooter2} to entity + + shoot an arrow from {_shooter2}: + set {_other} to event-projectile + shoot a pig from {_shooter}: + assert (shooter of {_other}) = {_shooter2} with "ExprShooter did not get shooter of other projectile" + set {_projectile} to entity + clear entity within {_other} + clear entity within {_projectile} + + set {_pigs::*} to pig, pig, pig, pig and pig + shoot {_pigs::*} from {_shooter}: + add entity to {_projectiles::*} + assert shooter = {_shooter} with "ExprShooter does not return shooter used in effect" + assert size of {_projectiles::*} = 5 with "1 or more projectiles did not spawn" + loop {_projectiles::*}: + assert loop-value is a pig with "Projectile on loop %loop-iteration% is not a pig" + clear entities within {_projectiles::*} + clear {_projectiles::*} + + clear entity within {_shooter} + clear entity within {_shooter2} diff --git a/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk b/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk index 30d4fc0cbf0..f19fdcd50c2 100644 --- a/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk +++ b/src/test/skript/tests/syntaxes/sections/EffSecSpawn.sk @@ -54,13 +54,13 @@ test "spawn salmon by variant" when running minecraft "1.21.2": set {_l} to test-location spawn 5 small salmon at {_l} assert size of all small salmons = 5 with "Size of all small salmons is not 5" - assert size of all salmons = 5 with "Size of all salmons is not 5" + assert size of all entities of type salmon = 5 with "Size of all salmons is not 5" spawn 3 medium salmon at {_l} assert size of all medium salmons = 3 with "Size of all medium salmons is not 3" - assert size of all salmons = 8 with "Size of all salmons is not 8" + assert size of all entities of type salmon = 8 with "Size of all salmons is not 8" spawn 2 large salmon at {_l} assert size of all large salmons = 2 with "Size of all large salmon is not 2" - assert size of all salmons = 10 with "Size of all salmon is not 10" + assert size of all entities of type salmon = 10 with "Size of all salmon is not 10" delete all large salmons assert size of all large salmons = 0 with "Large salmons did not get cleared" delete all medium salmons @@ -68,9 +68,9 @@ test "spawn salmon by variant" when running minecraft "1.21.2": delete all small salmons assert size of all small salmons = 0 with "Small salmons did not get cleared" spawn 15 of any salmon at {_l} - assert size of all salmons = 15 with "Size of all salmons is not 15" + assert size of all entities of type salmon = 15 with "Size of all salmons is not 15" clear all salmons - assert size of all salmons = 0 with "All salmons did not get cleared" + assert size of all entities of type salmon = 0 with "All salmons did not get cleared" test "spawn entities": set {_entities::*} to "allay", "axolotl", "bat", "bee", "blaze", "cat", "cave spider", "chicken" and "cod"