mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
documentation + fix toggles for admins
This commit is contained in:
parent
3229705012
commit
5b44e39bec
@ -41,7 +41,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
command = "bo3",
|
command = "bo3",
|
||||||
aliases = {"bo2"},
|
aliases = {"bo2"},
|
||||||
description = "Mark a plot as done",
|
description = "Mark a plot as done",
|
||||||
permission = "plots.done",
|
permission = "plots.bo3",
|
||||||
category = CommandCategory.ACTIONS,
|
category = CommandCategory.ACTIONS,
|
||||||
requiredType = RequiredType.NONE
|
requiredType = RequiredType.NONE
|
||||||
)
|
)
|
||||||
|
@ -99,7 +99,6 @@ public class DebugExec extends SubCommand {
|
|||||||
engine.eval(script, scope);
|
engine.eval(script, scope);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,143 @@
|
|||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
import com.plotsquared.general.commands.Command;
|
||||||
|
|
||||||
|
public class GenerateDocs {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
MainCommand.getInstance().addCommand(new WE_Anywhere());
|
||||||
|
MainCommand.getInstance().addCommand(new Cluster());
|
||||||
|
ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
||||||
|
log("### Want to document some commands?");
|
||||||
|
log(" - This page is automatically generated");
|
||||||
|
log(" - Fork the project and add a javadoc comment to one of the command classes");
|
||||||
|
log(" - Then do a pull request and it will be added to this page");
|
||||||
|
log("");
|
||||||
|
log("# Contents");
|
||||||
|
for (CommandCategory category : CommandCategory.values()) {
|
||||||
|
log("###### " + category.name());
|
||||||
|
for (Command<PlotPlayer> command : MainCommand.getCommands(category, null)) {
|
||||||
|
log(" - [/plot " + command.getCommand() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getCommand() +") ");
|
||||||
|
}
|
||||||
|
log("");
|
||||||
|
}
|
||||||
|
log("# Commands");
|
||||||
|
for (Command<PlotPlayer> command : commands) {
|
||||||
|
printCommand(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printCommand(Command<PlotPlayer> command) {
|
||||||
|
try {
|
||||||
|
String clazz = command.getClass().getSimpleName();
|
||||||
|
String name = command.getCommand();
|
||||||
|
|
||||||
|
// Header
|
||||||
|
String source = "https://github.com/IntellectualSites/PlotSquared/tree/master/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java";
|
||||||
|
log("## [" + name.toUpperCase() + "](" + source + ") ");
|
||||||
|
|
||||||
|
File file = new File("src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
|
||||||
|
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||||
|
List<String> perms = getPerms(name, lines);
|
||||||
|
String comment = getComments(lines);
|
||||||
|
|
||||||
|
log("#### Description");
|
||||||
|
log("`" + command.getDescription() + "`");
|
||||||
|
if (comment.length() > 0) {
|
||||||
|
log("##### Comments");
|
||||||
|
log("``` java");
|
||||||
|
log(comment);
|
||||||
|
log("```");
|
||||||
|
}
|
||||||
|
|
||||||
|
log("#### Usage");
|
||||||
|
log("`" + command.getUsage().replaceAll("\\{label\\}", "plot") + "`");
|
||||||
|
|
||||||
|
|
||||||
|
if (command.getRequiredType() != RequiredType.NONE) {
|
||||||
|
log("#### Required callers");
|
||||||
|
log("`" + command.getRequiredType().name() + "`");
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> aliases = command.getAliases();
|
||||||
|
if (aliases.size() > 0) {
|
||||||
|
log("#### Aliases");
|
||||||
|
log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||||
|
}
|
||||||
|
|
||||||
|
log("#### Permissions");
|
||||||
|
log("##### Primary");
|
||||||
|
log(" - `" + command.getPermission() + "` ");
|
||||||
|
if (perms.size() > 0) {
|
||||||
|
log("");
|
||||||
|
log("##### Other");
|
||||||
|
log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
||||||
|
}
|
||||||
|
log("");
|
||||||
|
log("***");
|
||||||
|
log("");
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getPerms(String cmd, List<String> lines) {
|
||||||
|
ArrayList<String> perms = new ArrayList<String>();
|
||||||
|
Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.contains("Permissions.hasPermission(")) {
|
||||||
|
Matcher m = p.matcher(line);
|
||||||
|
while (m.find()) {
|
||||||
|
String perm = m.group(1);
|
||||||
|
if (perm.endsWith(".")) {
|
||||||
|
perm += "<arg>";
|
||||||
|
}
|
||||||
|
if (perm.startsWith(".")) {
|
||||||
|
perms.set(perms.size() - 1, perms.get(perms.size() - 1) + perm);
|
||||||
|
}
|
||||||
|
else if (perm.contains(".")) {
|
||||||
|
perms.add(perm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (cmd.toLowerCase()) {
|
||||||
|
case "auto":
|
||||||
|
case "claim": {
|
||||||
|
perms.add("plots.plot.#");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return perms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getComments(List<String> lines) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (String line : lines) {
|
||||||
|
line = line.trim();
|
||||||
|
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
|
||||||
|
line = (line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "")).trim();
|
||||||
|
result.append(line + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void log(String s) {
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
|
||||||
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
|
||||||
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
|
||||||
*
|
|
||||||
* >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32
|
|
||||||
*/
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
@ -238,14 +238,6 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final int biome = BlockManager.manager.getBiomeFromString(args[1]);
|
final int biome = BlockManager.manager.getBiomeFromString(args[1]);
|
||||||
/*
|
|
||||||
* for (Biome b : Biome.values()) {
|
|
||||||
* if (b.toString().equalsIgnoreCase(args[1])) {
|
|
||||||
* biome = b;
|
|
||||||
* break;
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
if (biome == -1) {
|
if (biome == -1) {
|
||||||
MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList()));
|
MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList()));
|
||||||
return true;
|
return true;
|
||||||
|
@ -178,7 +178,7 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public void removeAttribute(String key) {
|
public void removeAttribute(String key) {
|
||||||
key = "plotsquared_user_attributes." + key;
|
key = "plotsquared_user_attributes." + key;
|
||||||
if (EconHandler.manager == null) {
|
if (EconHandler.manager == null || player.hasPermission("plotsquared_user_attributes.*")) {
|
||||||
deleteMeta(key);
|
deleteMeta(key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user