geforkt von Mirrors/Paper
Added /xp and /toggledownfall commands from vanilla
By: Nathan Adams <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
5be8bd5ba5
Commit
1c103e443d
@ -40,6 +40,8 @@ public class SimpleCommandMap implements CommandMap {
|
|||||||
fallbackCommands.add(new KillCommand());
|
fallbackCommands.add(new KillCommand());
|
||||||
fallbackCommands.add(new GameModeCommand());
|
fallbackCommands.add(new GameModeCommand());
|
||||||
fallbackCommands.add(new HelpCommand());
|
fallbackCommands.add(new HelpCommand());
|
||||||
|
fallbackCommands.add(new ExpCommand());
|
||||||
|
fallbackCommands.add(new ToggleDownfallCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleCommandMap(final Server server) {
|
public SimpleCommandMap(final Server server) {
|
||||||
|
48
paper-api/src/main/java/org/bukkit/command/defaults/ExpCommand.java
Normale Datei
48
paper-api/src/main/java/org/bukkit/command/defaults/ExpCommand.java
Normale Datei
@ -0,0 +1,48 @@
|
|||||||
|
package org.bukkit.command.defaults;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ExpCommand extends VanillaCommand {
|
||||||
|
public ExpCommand() {
|
||||||
|
super("xp");
|
||||||
|
this.description = "Gives the specified player a certain amount of experience";
|
||||||
|
this.usageMessage = "/xp <player> <amount>";
|
||||||
|
this.setPermission("bukkit.command.xp");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||||
|
if (!testPermission(sender)) return true;
|
||||||
|
if (args.length != 2) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayerExact(args[0]);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
try {
|
||||||
|
int exp = Integer.parseInt(args[1]);
|
||||||
|
|
||||||
|
Command.broadcastCommandMessage(sender, "Giving " + exp + " exp to " + player.getName());
|
||||||
|
|
||||||
|
player.giveExp(exp);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
sender.sendMessage("Invalid exp count: " + args[1]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Can't find user " + args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(String input) {
|
||||||
|
return input.startsWith("xp ") || input.equalsIgnoreCase("xp");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package org.bukkit.command.defaults;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ToggleDownfallCommand extends VanillaCommand {
|
||||||
|
public ToggleDownfallCommand() {
|
||||||
|
super("toggledownfall");
|
||||||
|
this.description = "Toggles rain on/off on a given world";
|
||||||
|
this.usageMessage = "/toggledownfall";
|
||||||
|
this.setPermission("bukkit.command.toggledownfall");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||||
|
if (!testPermission(sender)) return true;
|
||||||
|
|
||||||
|
World world = null;
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
world = Bukkit.getWorld(args[0]);
|
||||||
|
|
||||||
|
if (world == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "No world exists with the name '" + args[0] + "'");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (sender instanceof Player) {
|
||||||
|
world = ((Player)sender).getWorld();
|
||||||
|
} else {
|
||||||
|
world = Bukkit.getWorlds().get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Command.broadcastCommandMessage(sender, "Toggling downfall " + (world.hasStorm() ? "off" : "on") + " for world '" + world.getName() + "'");
|
||||||
|
world.setStorm(!world.hasStorm());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(String input) {
|
||||||
|
return input.startsWith("toggledownfall");
|
||||||
|
}
|
||||||
|
}
|
@ -104,6 +104,8 @@ public final class CommandPermissions {
|
|||||||
DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
|
DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
|
||||||
DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);
|
DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);
|
||||||
DefaultPermissions.registerPermission(PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
|
DefaultPermissions.registerPermission(PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
|
||||||
|
DefaultPermissions.registerPermission(PREFIX + "xp", "Allows the user to give themselves or others arbitrary values of experience", PermissionDefault.OP, commands);
|
||||||
|
DefaultPermissions.registerPermission(PREFIX + "toggledownfall", "Allows the user to toggle rain on/off for a given world", PermissionDefault.OP, commands);
|
||||||
|
|
||||||
commands.recalculatePermissibles();
|
commands.recalculatePermissibles();
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren