summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/Bukkit.java16
-rw-r--r--src/main/java/org/bukkit/Server.java17
-rw-r--r--src/main/java/org/bukkit/command/SimpleCommandMap.java2
-rw-r--r--src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java53
-rw-r--r--src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java79
5 files changed, 166 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 1014274e..b173ac7a 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -666,7 +666,7 @@ public final class Bukkit {
}
/**
- * @see Server#loadServerIcon(File)()
+ * @see Server#loadServerIcon(File)
*/
public static CachedServerIcon loadServerIcon(File file) throws Exception {
return server.loadServerIcon(file);
@@ -678,4 +678,18 @@ public final class Bukkit {
public static CachedServerIcon loadServerIcon(BufferedImage image) throws Exception {
return server.loadServerIcon(image);
}
+
+ /**
+ * @see Server#setIdleTimeout(int)
+ */
+ public static void setIdleTimeout(int threshold) {
+ server.setIdleTimeout(threshold);
+ }
+
+ /**
+ * @see Server#getIdleTimeout()
+ */
+ public static int getIdleTimeout() {
+ return server.getIdleTimeout();
+ }
}
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 1eb32b78..5c9d2c7a 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -782,4 +782,21 @@ public interface Server extends PluginMessageRecipient {
* ServerListPingEvent#setServerIcon(CachedServerIcon)}
*/
CachedServerIcon loadServerIcon(BufferedImage image) throws IllegalArgumentException, Exception;
+
+ /**
+ * Set the idle kick timeout. Any players idle for the specified amount of
+ * time will be automatically kicked.
+ * <p>
+ * A value of 0 will disable the idle kick timeout.
+ *
+ * @param threshold the idle timeout in minutes
+ */
+ public void setIdleTimeout(int threshold);
+
+ /**
+ * Gets the idle kick timeout.
+ *
+ * @return the idle timeout in minutes
+ */
+ public int getIdleTimeout();
}
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index c2f488a7..d178ad0f 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -61,6 +61,8 @@ public class SimpleCommandMap implements CommandMap {
fallbackCommands.add(new ScoreboardCommand());
fallbackCommands.add(new PlaySoundCommand());
fallbackCommands.add(new SpreadPlayersCommand());
+ fallbackCommands.add(new SetWorldSpawnCommand());
+ fallbackCommands.add(new SetIdleTimeoutCommand());
}
public SimpleCommandMap(final Server server) {
diff --git a/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java b/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java
new file mode 100644
index 00000000..6b8bb2d2
--- /dev/null
+++ b/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java
@@ -0,0 +1,53 @@
+package org.bukkit.command.defaults;
+
+import com.google.common.collect.ImmutableList;
+
+import org.apache.commons.lang.Validate;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.List;
+
+public class SetIdleTimeoutCommand extends VanillaCommand {
+
+ public SetIdleTimeoutCommand() {
+ super("setidletimeout");
+ this.description = "Sets the server's idle timeout";
+ this.usageMessage = "/setidletimeout <Minutes until kick>";
+ this.setPermission("bukkit.command.setidletimeout");
+ }
+
+ @Override
+ public boolean execute(CommandSender sender, String currentAlias, String[] args) {
+ if (!testPermission(sender)) return true;
+
+ if (args.length == 1) {
+ int minutes;
+
+ try {
+ minutes = getInteger(sender, args[0], 0, Integer.MAX_VALUE, true);
+ } catch (NumberFormatException ex) {
+ sender.sendMessage(ex.getMessage());
+ return true;
+ }
+
+ Bukkit.getServer().setIdleTimeout(minutes);
+
+ Command.broadcastCommandMessage(sender, "Successfully set the idle timeout to " + minutes + " minutes.");
+ return true;
+ }
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
+ Validate.notNull(sender, "Sender cannot be null");
+ Validate.notNull(args, "Arguments cannot be null");
+ Validate.notNull(alias, "Alias cannot be null");
+
+ return ImmutableList.of();
+ }
+}
diff --git a/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java b/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java
new file mode 100644
index 00000000..59c50591
--- /dev/null
+++ b/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java
@@ -0,0 +1,79 @@
+package org.bukkit.command.defaults;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang.Validate;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+
+public class SetWorldSpawnCommand extends VanillaCommand {
+
+ public SetWorldSpawnCommand() {
+ super("setworldspawn");
+ this.description = "Sets a worlds's spawn point. If no coordinates are specified, the player's coordinates will be used.";
+ this.usageMessage = "/setworldspawn OR /setworldspawn <x> <y> <z>";
+ this.setPermission("bukkit.command.setworldspawn");
+ }
+
+ @Override
+ public boolean execute(CommandSender sender, String currentAlias, String[] args) {
+ if (!testPermission(sender)) return true;
+
+ Player player = null;
+ World world;
+ if (sender instanceof Player) {
+ player = (Player) sender;
+ world = player.getWorld();
+ } else {
+ world = Bukkit.getWorlds().get(0);
+ }
+
+ final int x, y, z;
+
+ if (args.length == 0) {
+ if (player == null) {
+ sender.sendMessage("You can only perform this command as a player");
+ return true;
+ }
+
+ Location location = player.getLocation();
+
+ x = location.getBlockX();
+ y = location.getBlockY();
+ z = location.getBlockZ();
+ } else if (args.length == 3) {
+ try {
+ x = getInteger(sender, args[0], MIN_COORD, MAX_COORD, true);
+ y = getInteger(sender, args[1], 0, world.getMaxHeight(), true);
+ z = getInteger(sender, args[2], MIN_COORD, MAX_COORD, true);
+ } catch (NumberFormatException ex) {
+ sender.sendMessage(ex.getMessage());
+ return true;
+ }
+ } else {
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ world.setSpawnLocation(x, y, z);
+
+ Command.broadcastCommandMessage(sender, "Set world " + world.getName() + "'s spawnpoint to (" + x + ", " + y + ", " + z + ")");
+ return true;
+
+ }
+
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
+ Validate.notNull(sender, "Sender cannot be null");
+ Validate.notNull(args, "Arguments cannot be null");
+ Validate.notNull(alias, "Alias cannot be null");
+
+ return ImmutableList.of();
+ }
+}