Skip to content

Commit

Permalink
Merge pull request #6670 from SkriptLang/feature/deprecate-outdated-u…
Browse files Browse the repository at this point in the history
…tils

Housekeeping: deprecate, replace or remove archaic utilities classes.

-----

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
Co-authored-by: kiip1 <25848425+kiip1@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 1, 2025
2 parents e1ac6d0 + bf70e64 commit dadf750
Show file tree
Hide file tree
Showing 101 changed files with 959 additions and 2,673 deletions.
260 changes: 1 addition & 259 deletions src/main/java/ch/njol/skript/ScriptLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ public static CompletableFuture<ScriptInfo> loadScripts(Set<File> files, OpenClo
* and closed after the {@link Structure#postLoad()} stage.
* @return Info on the loaded scripts.
*/
@SuppressWarnings("removal")
private static CompletableFuture<ScriptInfo> loadScripts(List<Config> configs, OpenCloseable openCloseable) {
if (configs.isEmpty()) // Nothing to load
return CompletableFuture.completedFuture(new ScriptInfo());
Expand Down Expand Up @@ -1189,265 +1190,6 @@ public static EventRegistry<LoaderEvent> eventRegistry() {
return eventRegistry;
}

/*
* Deprecated stuff
*
* These fields / methods are from the old version of ScriptLoader,
* and are merely here for backwards compatibility.
*
* Some methods have been replaced by ParserInstance, some
* by new methods in this class.
*/

/**
* Unloads the provided script.
* @param scriptFile The file representing the script to unload.
* @return Statistics for the unloaded script.
* @deprecated Use {@link #unloadScript(Script)}.
*/
@Deprecated
public static ScriptInfo unloadScript(File scriptFile) {
Script script = getScript(scriptFile);
if (script != null)
return unloadScript(script);
return new ScriptInfo();
}

/**
* Unloads all scripts present in the provided folder.
* @param folder The folder containing scripts to unload.
* @return Combined statistics for the unloaded scripts.
* This data is calculated by using {@link ScriptInfo#add(ScriptInfo)}.
* @deprecated Use {@link #unloadScripts(Set)}.
*/
@Deprecated
private static ScriptInfo unloadScripts(File folder) {
return unloadScripts(getScripts(folder));
}

/**
* Reloads a single script.
* @param scriptFile The file representing the script to reload.
* @return Future of statistics of the newly loaded script.
* @deprecated Use {@link #reloadScript(Script, OpenCloseable)}.
*/
@Deprecated
public static CompletableFuture<ScriptInfo> reloadScript(File scriptFile, OpenCloseable openCloseable) {
unloadScript(scriptFile);
return loadScripts(scriptFile, openCloseable);
}

/**
* Reloads all scripts in the given folder and its subfolders.
* @param folder A folder.
* @return Future of statistics of newly loaded scripts.
* @deprecated Use {@link #reloadScripts}.
*/
@Deprecated
public static CompletableFuture<ScriptInfo> reloadScripts(File folder, OpenCloseable openCloseable) {
unloadScripts(folder);
return loadScripts(folder, openCloseable);
}

/**
* @deprecated Use <b>{@link #getLoadedScripts()}.size()</b>.
*/
@Deprecated
public static int loadedScripts() {
return getLoadedScripts().size();
}

/**
* @deprecated Use <b>{@link #getLoadedScripts()}</b> and <b>{@link Script#getStructures()}.size()</b>.
* Please note that a Structure may have multiple triggers, and this is only an estimate.
*/
@Deprecated
public static int loadedTriggers() {
int loaded = 0;
for (Script script : getLoadedScripts())
loaded += script.getStructures().size();
return loaded;
}

/**
* @deprecated Use {@link #loadScripts(File, OpenCloseable)}
*/
@Deprecated
static void loadScripts() {
unloadScripts(getLoadedScripts());
loadScripts(Skript.getInstance().getScriptsFolder(), OpenCloseable.EMPTY).join();
}

/**
* @deprecated Callers should not be using configs. Use {@link #loadScripts(Set, OpenCloseable)}.
*/
@Deprecated
public static ScriptInfo loadScripts(List<Config> configs) {
return loadScripts(configs, OpenCloseable.EMPTY).join();
}

/**
* @deprecated Callers should not be using configs. Use {@link #loadScripts(Set, OpenCloseable)}.
* @see RetainingLogHandler
*/
@Deprecated
public static ScriptInfo loadScripts(List<Config> configs, List<LogEntry> logOut) {
RetainingLogHandler logHandler = new RetainingLogHandler();
try {
return loadScripts(configs, logHandler).join();
} finally {
logOut.addAll(logHandler.getLog());
}
}

/**
* @deprecated Callers should not be using configs. Use {@link #loadScripts(Set, OpenCloseable)}.
*/
@Deprecated
public static ScriptInfo loadScripts(Config... configs) {
return loadScripts(Arrays.asList(configs), OpenCloseable.EMPTY).join();
}

/**
* @deprecated Use {@link #reloadScript(Script, OpenCloseable)}.
*/
@Deprecated
public static ScriptInfo reloadScript(File script) {
return reloadScript(script, OpenCloseable.EMPTY).join();
}

/**
* @deprecated Use {@link #reloadScripts(Set, OpenCloseable)}.
*/
@Deprecated
public static ScriptInfo reloadScripts(File folder) {
return reloadScripts(folder, OpenCloseable.EMPTY).join();
}

/**
* @deprecated Use {@link ParserInstance#getHasDelayBefore()}.
*/
@Deprecated
public static Kleenean getHasDelayBefore() {
return getParser().getHasDelayBefore();
}

/**
* @deprecated Use {@link ParserInstance#setHasDelayBefore(Kleenean)}.
*/
@Deprecated
public static void setHasDelayBefore(Kleenean hasDelayBefore) {
getParser().setHasDelayBefore(hasDelayBefore);
}

/**
* @deprecated Use {@link ParserInstance#getCurrentScript()}.
*/
@Nullable
@Deprecated
public static Config getCurrentScript() {
ParserInstance parser = getParser();
return parser.isActive() ? parser.getCurrentScript().getConfig() : null;
}

/**
* @deprecated Addons should no longer be modifying this.
*/
@Deprecated
public static void setCurrentScript(@Nullable Config currentScript) {
getParser().setCurrentScript(currentScript);
}

/**
* @deprecated Use {@link ParserInstance#getCurrentSections()}.
*/
@Deprecated
public static List<TriggerSection> getCurrentSections() {
return getParser().getCurrentSections();
}

/**
* @deprecated Use {@link ParserInstance#setCurrentSections(List)}.
*/
@Deprecated
public static void setCurrentSections(List<TriggerSection> currentSections) {
getParser().setCurrentSections(currentSections);
}

/**
* @deprecated Use {@link ParserInstance#getCurrentSections(Class)}.
*/
@Deprecated
public static List<SecLoop> getCurrentLoops() {
return getParser().getCurrentSections(SecLoop.class);
}

/**
* @deprecated Never use this method, it has no effect.
*/
@Deprecated
public static void setCurrentLoops(List<SecLoop> currentLoops) { }

/**
* @deprecated Use {@link ParserInstance#getCurrentEventName()}.
*/
@Nullable
@Deprecated
public static String getCurrentEventName() {
return getParser().getCurrentEventName();
}

/**
* @deprecated Use {@link ParserInstance#setCurrentEvent(String, Class[])}.
*/
@SafeVarargs
@Deprecated
public static void setCurrentEvent(String name, @Nullable Class<? extends Event>... events) {
getParser().setCurrentEvent(name, events);
}

/**
* @deprecated Use {@link ParserInstance#deleteCurrentEvent()}.
*/
@Deprecated
public static void deleteCurrentEvent() {
getParser().deleteCurrentEvent();
}

/**
* @deprecated Use {@link ParserInstance#isCurrentEvent(Class)}
*/
@Deprecated
public static boolean isCurrentEvent(@Nullable Class<? extends Event> event) {
return getParser().isCurrentEvent(event);
}

/**
* @deprecated Use {@link ParserInstance#isCurrentEvent(Class[])}.
*/
@SafeVarargs
@Deprecated
public static boolean isCurrentEvent(Class<? extends Event>... events) {
return getParser().isCurrentEvent(events);
}

/**
* @deprecated Use {@link ParserInstance#getCurrentEvents()}.
*/
@Nullable
@Deprecated
public static Class<? extends Event>[] getCurrentEvents() {
return getParser().getCurrentEvents();
}

/**
* @deprecated This method has no functionality, it just returns its input.
*/
@Deprecated
public static Config loadStructure(Config config) {
return config;
}

/**
* Gets a script's file from its name, if one exists.
* @param script The script name/path
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ public static Metrics getMetrics() {
return metrics;
}

@SuppressWarnings("null")
@SuppressWarnings({"null", "removal"})
private final static Collection<Closeable> closeOnDisable = Collections.synchronizedCollection(new ArrayList<Closeable>());

/**
Expand All @@ -1134,6 +1134,7 @@ public static Metrics getMetrics() {
*
* @param closeable
*/
@SuppressWarnings("removal")
public static void closeOnDisable(final Closeable closeable) {
closeOnDisable.add(closeable);
}
Expand Down Expand Up @@ -1217,6 +1218,7 @@ private void beforeDisable() {
}

@Override
@SuppressWarnings("removal")
public void onDisable() {
if (disabled)
return;
Expand Down Expand Up @@ -1336,7 +1338,7 @@ private static void stopAcceptingRegistrations() {
/**
* 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 plugin The plugin
*/
public static SkriptAddon registerAddon(JavaPlugin plugin) {
Expand Down Expand Up @@ -1420,7 +1422,7 @@ private static SyntaxOrigin getSyntaxOrigin(JavaPlugin plugin) {

/**
* Registers a {@link Condition}.
*
*
* @param conditionClass The condition's class
* @param patterns Skript patterns to match this condition
*/
Expand All @@ -1447,7 +1449,7 @@ public static <E extends Condition> void registerCondition(Class<E> conditionCla

/**
* Registers an {@link Effect}.
*
*
* @param effectClass The effect's class
* @param patterns Skript patterns to match this effect
*/
Expand Down Expand Up @@ -1508,7 +1510,7 @@ public static <E extends Section> void registerSection(Class<E> sectionClass, St

/**
* Registers an expression.
*
*
* @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.
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ public static EventRegistry<Event> eventRegistry() {
public static final Option<String> effectCommandToken = new Option<>("effect command token", "!");
public static final Option<Boolean> allowOpsToUseEffectCommands = new Option<>("allow ops to use effect commands", false);

/*
* @deprecated Will be removed in 2.8.0. Use {@link #logEffectCommands} instead.
*/
@Deprecated
public static final Option<Boolean> logPlayerCommands = new Option<>("log player commands", false).optional(true);
public static final Option<Boolean> logEffectCommands = new Option<>("log effect commands", false);

// everything handled by Variables
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/ch/njol/skript/classes/Arithmetic.java

This file was deleted.

Loading

0 comments on commit dadf750

Please sign in to comment.