Skip to content

Commit

Permalink
Resolve issue SkriptLang#1825: add info command
Browse files Browse the repository at this point in the history
  • Loading branch information
Olyno committed Oct 18, 2019
1 parent 389cdcb commit 7321cca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
42 changes: 4 additions & 38 deletions src/main/java/ch/njol/skript/SkriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand All @@ -42,9 +39,6 @@
import ch.njol.skript.localization.PluralizingArgsMessage;
import ch.njol.skript.log.RedirectingLogHandler;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.skript.tests.runner.SkriptTestEvent;
import ch.njol.skript.tests.runner.TestMode;
import ch.njol.skript.tests.runner.TestTracker;
import ch.njol.skript.update.ReleaseStatus;
import ch.njol.skript.update.UpdaterState;
import ch.njol.skript.util.Color;
Expand Down Expand Up @@ -100,6 +94,7 @@ public class SkriptCommand implements CommandExecutor {
.add("check")
.add("changes")
.add("download")
).add("info"
// ).add(new CommandHelp("variable", "Commands for modifying variables", ChatColor.DARK_RED)
// .add("set", "Creates a new variable or changes an existing one")
// .add("delete", "Deletes a variable")
Expand All @@ -110,9 +105,6 @@ public class SkriptCommand implements CommandExecutor {
if (new File(Skript.getInstance().getDataFolder() + "/doc-templates").exists()) {
skriptCommandHelp.add("gen-docs");
}
if (TestMode.DEV_MODE) { // Add command to run individual tests
skriptCommandHelp.add("test");
}
}

private final static ArgsMessage m_reloading = new ArgsMessage(NODE + ".reload.reloading");
Expand Down Expand Up @@ -334,6 +326,9 @@ public boolean onCommand(final @Nullable CommandSender sender, final @Nullable C
} else if (args[1].equalsIgnoreCase("download")) {
updater.updateCheck(sender);
}
} else if (args[0].equalsIgnoreCase("info")) {
info(sender, "info.aliases");
info(sender, "info.documentation");
} else if (args[0].equalsIgnoreCase("help")) {
skriptCommandHelp.showHelp(sender);
} else if (args[0].equalsIgnoreCase("gen-docs")) {
Expand All @@ -348,35 +343,6 @@ public boolean onCommand(final @Nullable CommandSender sender, final @Nullable C
Skript.info(sender, "Generating docs...");
generator.generate(); // Try to generate docs... hopefully
Skript.info(sender, "Documentation generated!");
} else if (args[0].equalsIgnoreCase("test") && TestMode.DEV_MODE) {
File script;
if (args.length == 1) {
script = TestMode.lastTestFile;
if (script == null) {
Skript.error(sender, "No test script has been run yet!");
return true;
}
} else {
script = TestMode.TEST_DIR.resolve(
Arrays.stream(args).skip(1).collect(Collectors.joining(" ")) + ".sk").toFile();
TestMode.lastTestFile = script;
}
assert script != null;
if (!script.exists()) {
Skript.error(sender, "Test script doesn't exist!");
return true;
}

ScriptLoader.loadScripts(ScriptLoader.loadStructure(script)); // Load test
Bukkit.getPluginManager().callEvent(new SkriptTestEvent()); // Run it
Skript.disableScripts(); // Clean state for next test

// Get results and show them
String[] lines = TestTracker.collectResults().createReport().split("\n");
for (String line : lines) {
assert line != null;
Skript.info(sender, line);
}
}
} catch (final Exception e) {
Skript.exception(e, "Exception occurred in Skript's main command", "Used command: /" + label + " " + StringUtils.join(args, " "));
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/lang/english.lang
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ skript command:
check: Checks for a new version
changes: Lists all changes since the current version
download: Download the newest version
info: Prints a message with links to Skript's aliases and documentation
gen-docs: Generates documentation using doc-templates in plugin folder

invalid script: Can't find the script <grey>'<gold>%s<grey>'<red> in the scripts folder!
Expand Down Expand Up @@ -132,6 +133,9 @@ skript command:
# invalid version: No changelog for the version <gold>%s<red> available
title: <bold><cyan>%s<reset> (%s)
next page: <grey>page %s of %s. Type <gold>/skript update changes %s<gray> for the next page (hint: use the up arrow key)
info:
aliases: Skript's aliases can be found here: <aqua>https://github.com/SkriptLang/skript-aliases
documentation: Skript's documentation can be found here: <aqua>https://skriptlang.github.io/Skript

# -- Updater --
updater:
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/lang/german.lang
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ skript command:
check: Überprüft, ob eine neue Version von Skript verfügbar ist
changes: Listet alle Änderungen seit der aktuellen Version auf (auf englisch)
download: Lädt die neueste Version herunter
info: Druckt eine Nachricht mit Links zu den Aliases und der Dokumentation von Skript.

invalid script: Das Skript <grey>'<gold>%s<grey>'<red> konnte nicht gefunden werden.
invalid folder: Der Ordner <grey>'<gold>%s<grey>'<red> konnte nicht gefunden werden.
Expand Down Expand Up @@ -133,6 +134,9 @@ skript command:
# invalid version: Kein Changelog der Version <gold>%s<red> verfügbar
title: <bold><cyan>%s<reset> (%s)
next page: <gray>Seite %s von %s. Tippe <gold>/skript update changes %s<gray> für die nächste Seite (Tipp: benutze die Pfeil-Hoch-Taste)
info:
aliases: Die Aliase von Skript finden Sie hier: <aqua>https://github.com/SkriptLang/skript-aliases
documentation: Die Dokumentation von Skript finden Sie hier: <aqua>https://skriptlang.github.io/Skript

# -- Updater --
updater:
Expand Down

0 comments on commit 7321cca

Please sign in to comment.