diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-03 00:41:22 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-03 00:41:22 +0100 |
commit | e1f69e08675f9b4a14d015eb1db0fa84ed0d1689 (patch) | |
tree | 43723a66a8f48d5938d4d706b9781d54a7bde6ce | |
parent | ce0d95972832a68db5f019fa2d830cd3fbbcb5db (diff) | |
download | bukkit-e1f69e08675f9b4a14d015eb1db0fa84ed0d1689.tar bukkit-e1f69e08675f9b4a14d015eb1db0fa84ed0d1689.tar.gz bukkit-e1f69e08675f9b4a14d015eb1db0fa84ed0d1689.tar.lz bukkit-e1f69e08675f9b4a14d015eb1db0fa84ed0d1689.tar.xz bukkit-e1f69e08675f9b4a14d015eb1db0fa84ed0d1689.zip |
Added the ability to access offline players & more reverse lookup fixes in Permissible.
-rw-r--r-- | src/main/java/org/bukkit/Bukkit.java | 6 | ||||
-rw-r--r-- | src/main/java/org/bukkit/Server.java | 10 | ||||
-rw-r--r-- | src/main/java/org/bukkit/command/CommandSender.java | 7 | ||||
-rw-r--r-- | src/main/java/org/bukkit/command/ConsoleCommandSender.java | 4 | ||||
-rw-r--r-- | src/main/java/org/bukkit/command/SimpleCommandMap.java | 31 | ||||
-rw-r--r-- | src/main/java/org/bukkit/entity/Player.java | 3 | ||||
-rw-r--r-- | src/main/java/org/bukkit/permissions/PermissibleBase.java | 2 | ||||
-rw-r--r-- | src/main/java/org/bukkit/plugin/SimplePluginManager.java | 16 |
8 files changed, 43 insertions, 36 deletions
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 5ab3f94e..ca1e537a 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -220,7 +220,11 @@ public final class Bukkit { server.shutdown(); } - public int broadcast(String message, String permission) { + public static int broadcast(String message, String permission) { return server.broadcast(message, permission); } + + public static OfflinePlayer getOfflinePlayer(String name) { + return server.getOfflinePlayer(name); + } } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 1edceb18..51b90f4e 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -375,4 +375,14 @@ public interface Server { * @return Amount of users who received the message */ public int broadcast(String message, String permission); + + /** + * Gets the player by the given name, regardless if they are offline or online. + * + * This will return an object even if the player does not exist. To this method, all players will exist. + * + * @param name Name of the player to retrieve + * @return OfflinePlayer object + */ + public OfflinePlayer getOfflinePlayer(String name); } diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java index 555ba1b3..7bc46c53 100644 --- a/src/main/java/org/bukkit/command/CommandSender.java +++ b/src/main/java/org/bukkit/command/CommandSender.java @@ -18,4 +18,11 @@ public interface CommandSender extends Permissible { * @return Server instance */ public Server getServer(); + + /** + * Gets the name of this command sender + * + * @return Name of the sender + */ + public String getName(); } diff --git a/src/main/java/org/bukkit/command/ConsoleCommandSender.java b/src/main/java/org/bukkit/command/ConsoleCommandSender.java index 72ba11ce..b63e8733 100644 --- a/src/main/java/org/bukkit/command/ConsoleCommandSender.java +++ b/src/main/java/org/bukkit/command/ConsoleCommandSender.java @@ -83,4 +83,8 @@ public class ConsoleCommandSender implements CommandSender { public Set<PermissionAttachmentInfo> getEffectivePermissions() { return perm.getEffectivePermissions(); } + + public String getName() { + return "CONSOLE"; + } } diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java index f2a02194..178edabb 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -1,31 +1,27 @@ package org.bukkit.command; +import org.bukkit.command.defaults.ReloadCommand; +import org.bukkit.command.defaults.PluginsCommand; import org.bukkit.command.defaults.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Iterator; + +import org.bukkit.ChatColor; import org.bukkit.Server; + +import org.bukkit.plugin.Plugin; import static org.bukkit.util.Java15Compat.Arrays_copyOfRange; public final class SimpleCommandMap implements CommandMap { private final Map<String, Command> knownCommands = new HashMap<String, Command>(); private final Set<String> aliases = new HashSet<String>(); private final Server server; - private static final Set<Command> fallbackCommands = new HashSet<Command>(); - - static { - fallbackCommands.add(new ListCommand()); - fallbackCommands.add(new StopCommand()); - fallbackCommands.add(new SaveCommand()); - fallbackCommands.add(new SaveOnCommand()); - fallbackCommands.add(new SaveOffCommand()); - fallbackCommands.add(new OpCommand()); - fallbackCommands.add(new DeopCommand()); - } public SimpleCommandMap(final Server server) { this.server = server; @@ -114,16 +110,6 @@ public final class SimpleCommandMap implements CommandMap { return registerdPassedLabel; } - private Command getFallback(String label) { - for (Command cmd : fallbackCommands) { - if (label.startsWith(cmd.getName().toLowerCase())) { - return cmd; - } - } - - return null; - } - /** * {@inheritDoc} */ @@ -137,9 +123,6 @@ public final class SimpleCommandMap implements CommandMap { String sentCommandLabel = args[0].toLowerCase(); Command target = getCommand(sentCommandLabel); if (target == null) { - target = getFallback(sentCommandLabel); - } - if (target == null) { return false; } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index f599f298..69d7e173 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -9,13 +9,14 @@ import org.bukkit.Material; import org.bukkit.Note; import org.bukkit.OfflinePlayer; import org.bukkit.Statistic; +import org.bukkit.command.CommandSender; import org.bukkit.map.MapView; /** * Represents a player, connected or not * */ -public interface Player extends HumanEntity, OfflinePlayer { +public interface Player extends HumanEntity, CommandSender, OfflinePlayer { /** * Gets the "friendly" name to display of this player. This may include color. * diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java index 8c2be973..ec6fb6ca 100644 --- a/src/main/java/org/bukkit/permissions/PermissibleBase.java +++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java @@ -159,7 +159,7 @@ public class PermissibleBase implements Permissible { dirtyPermissions = true; } - private synchronized void calculatePermissions() { + public synchronized void calculatePermissions() { if (dirtyPermissions) { clearPermissions(); Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp()); diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 1c25077a..0e611cc3 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -449,15 +449,13 @@ public final class SimplePluginManager implements PluginManager { } private void calculatePermissionDefault(Permission perm) { - if (!perm.getChildren().isEmpty()) { - if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) { - defaultPerms.get(true).add(perm); - dirtyPermissibles(true); - } - if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) { - defaultPerms.get(false).add(perm); - dirtyPermissibles(false); - } + if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) { + defaultPerms.get(true).add(perm); + dirtyPermissibles(true); + } + if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) { + defaultPerms.get(false).add(perm); + dirtyPermissibles(false); } } |