summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/command/SimpleCommandMap.java2
-rw-r--r--src/main/java/org/bukkit/command/defaults/ExpCommand.java48
-rw-r--r--src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java47
-rw-r--r--src/main/java/org/bukkit/util/permissions/CommandPermissions.java2
4 files changed, 99 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 603632ed..3f03ebcf 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -40,6 +40,8 @@ public class SimpleCommandMap implements CommandMap {
fallbackCommands.add(new KillCommand());
fallbackCommands.add(new GameModeCommand());
fallbackCommands.add(new HelpCommand());
+ fallbackCommands.add(new ExpCommand());
+ fallbackCommands.add(new ToggleDownfallCommand());
}
public SimpleCommandMap(final Server server) {
diff --git a/src/main/java/org/bukkit/command/defaults/ExpCommand.java b/src/main/java/org/bukkit/command/defaults/ExpCommand.java
new file mode 100644
index 00000000..71773fd2
--- /dev/null
+++ b/src/main/java/org/bukkit/command/defaults/ExpCommand.java
@@ -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");
+ }
+}
diff --git a/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java b/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java
new file mode 100644
index 00000000..d03ccecb
--- /dev/null
+++ b/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java
@@ -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");
+ }
+}
diff --git a/src/main/java/org/bukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
index 74394735..66952baa 100644
--- a/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
+++ b/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
@@ -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 + "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 + "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();