本文整理汇总了Java中com.plotsquared.general.commands.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于com.plotsquared.general.commands包,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
C.NOT_IN_PLOT.send(player);
return;
}
HashSet<RegionWrapper> regions = plot.getRegions();
final LocalBlockQueue queue = plot.getArea().getQueue(false);
ChunkManager.chunkTask(plot, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
queue.fixChunkLighting(value[0], value[1]);
}
}, new Runnable() {
@Override
public void run() {
plot.refreshChunks();
C.SET_BLOCK_ACTION_FINISHED.send(player);
}
}, 5);
}
示例2: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
checkTrue(plot.isAdded(player.getUUID()), C.NO_PLOT_PERMS);
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
if (plot.isOwner(player.getUUID())) {
checkTrue(plot.hasOwner(), C.ALREADY_OWNER);
// TODO setowner, other
} else {
UUID uuid = player.getUUID();
if (plot.isAdded(uuid)) {
if (plot.removeTrusted(uuid)) {
EventUtil.manager.callTrusted(player, plot, uuid, false);
}
if (plot.removeMember(uuid)) {
EventUtil.manager.callMember(player, plot, uuid, false);
}
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
} else {
MainUtil.sendMessage(player, C.REMOVED_PLAYERS, 1);
}
}
}
示例3: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length >= 1, C.COMMAND_SYNTAX, getUsage());
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()), C.NOW_OWNER);
checkTrue(plot.getRunning() == 0, C.WAIT_FOR_TIMER);
final PlotArea area = plot.getArea();
if (area instanceof SinglePlotArea) {
player.sendMessage("The command has been changed to: //cfi");
} else {
player.sendMessage("Must have the `worlds` component enabled in the PlotSquared config.yml");
return;
}
}
示例4: process
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws Command.CommandException, WorldEditException {
Actor actor = locals.get(Actor.class);
LocalSession session = worldEdit.getSessionManager().get(actor);
session.setTool(null, (Player) actor);
BrushTool tool = session.getBrushTool((Player) actor);
if (tool != null) {
tool.setPrimary(settings);
tool.setSecondary(settings);
BBC.BRUSH_EQUIPPED.send(actor, ((String) locals.get("arguments")).split(" ")[1]);
}
return null;
}
示例5: RegisterPlotCommands
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
public static void RegisterPlotCommands() {
Command<PlotPlayer> cmd = new Command<PlotPlayer>("middle", "/p middle", "Teleport you to the center of the plot", "plot.middle", new String[] { "center", "m" }, RequiredType.PLAYER) {
@Override
public boolean onCommand(PlotPlayer p, String[] args) {
Plot plot = p.getCurrentPlot();
if (plot == null) {
p.sendMessage(Util.parseColors("&7&l[&6&liZenith&f&lPlots&7&l] &6You are not in a plot."));
return false;
}
com.intellectualcrafters.plot.object.Location b = plot.getCorners()[0];
com.intellectualcrafters.plot.object.Location t = plot.getCorners()[1];
System.out.println(b + ", " + t);
double midX = b.getX() + t.getX();
midX = midX / 2;
double midZ = b.getZ() + t.getZ();
midZ = midZ / 2;
com.intellectualcrafters.plot.object.Location midLoc = null;
boolean isOnLand = false;
for (int y = 256; y >= 0; y--) {
midLoc = new com.intellectualcrafters.plot.object.Location(p.getLocation().getWorld(), (int) midX, y, (int) midZ);
if ((convLocation(midLoc).getBlock().getType() != Material.AIR)) {
isOnLand = true;
midLoc.add(0, 1, 0);
break;
}
}
BukkitPlayer bP = (BukkitPlayer) p;
if (!isOnLand) {
bP.setFlight(true);
}
p.sendMessage(Util.parseColors("&7&l[&6&liZenith&f&lPlots&7&l] &6You have been teleported to the center of the plot."));
p.teleport(midLoc);
return true;
}
};
MainCommand.getInstance().addCommand(cmd);
}
示例6: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_CLEAR), C.NO_PLOT_PERMS);
checkTrue(plot.getRunning() == 0, C.WAIT_FOR_TIMER);
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions.hasPermission(player, C.PERMISSION_CONTINUE), C.DONE_ALREADY_DONE);
confirm.run(this, new Runnable() {
@Override
public void run() {
final long start = System.currentTimeMillis();
boolean result = plot.clear(true, false, new Runnable() {
@Override
public void run() {
plot.unlink();
GlobalBlockQueue.IMP.addTask(new Runnable() {
@Override
public void run() {
plot.removeRunning();
// If the state changes, then mark it as no longer done
if (plot.getFlag(Flags.DONE).isPresent()) {
FlagManager.removePlotFlag(plot, Flags.DONE);
}
if (plot.getFlag(Flags.ANALYSIS).isPresent()) {
FlagManager.removePlotFlag(plot, Flags.ANALYSIS);
}
MainUtil.sendMessage(player, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
}
});
}
});
if (!result) {
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
} else {
plot.addRunning();
}
}
}, null);
}
示例7: onCommand
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public boolean onCommand(PlotPlayer player, String[] args) {
if (args.length == 0) {
return noArgs(player);
}
Command cmd = MainCommand.getInstance().getCommand("set" + args[0]);
if (cmd != null) {
if (!Permissions.hasPermission(player, cmd.getPermission(), true)) {
return false;
}
cmd.execute(player, Arrays.copyOfRange(args, 1, args.length), null, null);
return true;
}
// Additional checks
Plot plot = player.getCurrentPlot();
if (plot == null) {
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
return false;
}
// components
HashSet<String> components = new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
if (components.contains(args[0].toLowerCase())) {
return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length));
}
// flag
Flag<?> flag = FlagManager.getFlag(args[0].toLowerCase());
if (Flags.getFlags().contains(flag)) {
StringBuilder a = new StringBuilder();
if (args.length > 1) {
for (int x = 1; x < args.length; x++) {
a.append(" ").append(args[x]);
}
}
MainCommand.onCommand(player, ("flag set " + args[0] + a.toString()).split(" "));
return true;
}
return noArgs(player);
}
示例8: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
PlotAreaManager pam = PS.get().getPlotAreaManager();
if (!(pam instanceof SinglePlotAreaManager)) {
player.sendMessage("Must be a single plot area!");
return;
}
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
PlotId id = new PlotId(0, 0);
File container = PS.imp().getWorldContainer();
for (File folder : container.listFiles()) {
String name = folder.getName();
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromString(name) == null) {
UUID uuid = UUIDHandler.getUUID(name, null);
if (uuid == null) {
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
}
while (new File(container, id.toCommaSeparatedString()).exists()) {
id = Auto.getNextPlotId(id, 1);
}
File newDir = new File(container, id.toCommaSeparatedString());
if (folder.renameTo(newDir)) {
area.getPlot(id).setOwner(uuid);
}
}
}
player.sendMessage("Done!");
}
示例9: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"), C.NO_PLOT_PERMS);
if (plot.getRunning() != 0) {
C.WAIT_FOR_TIMER.send(player);
return;
}
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
final HashSet<RegionWrapper> regions = plot.getRegions();
final BiomeRegistry biomeRegistry = FaweAPI.getWorld(plot.getArea().worldname).getWorldData().getBiomeRegistry();
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
final BaseBiome biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
if (biome == null) {
String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), C.BLOCK_LIST_SEPARATER.s());
C.NEED_BIOME.send(player);
MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
return;
}
confirm.run(this, new Runnable() {
@Override
public void run() {
if (plot.getRunning() != 0) {
C.WAIT_FOR_TIMER.send(player);
return;
}
plot.addRunning();
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
EditSession session = new EditSessionBuilder(plot.getArea().worldname)
.autoQueue(false)
.checkMemory(false)
.allowedRegionsEverywhere()
.player(FawePlayer.wrap(player.getName()))
.limitUnlimited()
.build();
long seed = PseudoRandom.random.nextLong();
for (RegionWrapper region : regions) {
CuboidRegion cuboid = new CuboidRegion(new Vector(region.minX, 0, region.minZ), new Vector(region.maxX, 256, region.maxZ));
session.regenerate(cuboid, biome, seed);
}
session.flushQueue();
plot.removeRunning();
}
});
}
}, null);
}
示例10: printCommand
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
public static void printCommand(Command command) {
try {
String clazz = command.getClass().getSimpleName();
String name = command.getId();
// Header
String source =
"https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz
+ ".java";
GenerateDocs.log("## [" + name.toUpperCase() + "](" + source + ") ");
File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
List<String> perms = GenerateDocs.getPerms(name, lines);
List<String> usages = GenerateDocs.getUsage(name, lines);
String comment = GenerateDocs.getComments(lines);
GenerateDocs.log("#### Description");
GenerateDocs.log('`' + command.getDescription() + '`');
if (!comment.isEmpty()) {
GenerateDocs.log("##### Comments");
GenerateDocs.log("``` java");
GenerateDocs.log(comment);
GenerateDocs.log("```");
}
GenerateDocs.log("#### Usage ");
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
if (!usages.isEmpty() && !usages.get(0).equalsIgnoreCase(mainUsage)) {
GenerateDocs.log("##### Primary ");
GenerateDocs.log(" - `" + mainUsage + "` ");
GenerateDocs.log("");
GenerateDocs.log("##### Other ");
GenerateDocs.log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
GenerateDocs.log("");
} else {
GenerateDocs.log('`' + mainUsage + "` ");
}
if (command.getRequiredType() != RequiredType.NONE) {
GenerateDocs.log("#### Required callers");
GenerateDocs.log('`' + command.getRequiredType().name() + '`');
}
List<String> aliases = command.getAliases();
if (!aliases.isEmpty()) {
GenerateDocs.log("#### Aliases");
GenerateDocs.log('`' + StringMan.getString(command.getAliases()) + '`');
}
GenerateDocs.log("#### Permissions");
if (!perms.isEmpty()) {
GenerateDocs.log("##### Primary");
GenerateDocs.log(" - `" + command.getPermission() + "` ");
GenerateDocs.log("");
GenerateDocs.log("##### Other");
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + '`');
GenerateDocs.log("");
} else {
GenerateDocs.log('`' + command.getPermission() + "` ");
}
GenerateDocs.log("***");
GenerateDocs.log("");
} catch (IOException e) {
e.printStackTrace();
}
}
示例11: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
C.PLOT_NEAR.send(player, StringMan.join(plot.getPlayersInPlot(), ", "));
}
示例12: tab
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
return tabOf(player, args, space, getUsage());
}
示例13: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
onCommand(player, args);
}
示例14: Help
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
public Help(Command parent) {
super(parent, true);
}
示例15: execute
import com.plotsquared.general.commands.Command; //导入依赖的package包/类
@Override
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
checkTrue(args.length >= 1 && args.length <= 2, C.COMMAND_SYNTAX, getUsage());
final String arg0 = args[0].toLowerCase();
switch (arg0) {
case "add":
case "check":
if (!Permissions.hasPermission(player, C.PERMISSION_GRANT.f(arg0))) {
C.NO_PERMISSION.send(player, C.PERMISSION_GRANT.f(arg0));
return;
}
if (args.length > 2) {
break;
}
final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
if (uuid == null) {
C.INVALID_PLAYER.send(player, args[1]);
return;
}
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
@Override
public void run(byte[] array) {
if (arg0.equals("check")) { // check
int granted = array == null ? 0 : ByteArrayUtilities.bytesToInteger(array);
C.GRANTED_PLOTS.send(player, granted);
} else { // add
int amount = 1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array));
boolean replace = array != null;
String key = "grantedPlots";
byte[] rawData = ByteArrayUtilities.integerToBytes(amount);
PlotPlayer online = UUIDHandler.getPlayer(uuid);
if (online != null) {
online.setPersistentMeta(key, rawData);
} else {
DBFunc.addPersistentMeta(uuid, key, rawData, replace);
}
}
}
});
}
C.COMMAND_SYNTAX.send(player, getUsage());
}