diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-03 15:57:54 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-03 15:57:54 +0100 |
commit | c8d77561b16e9edc75b05a10f546ef919a717a92 (patch) | |
tree | b6c5e323156d7aa250024b73f9e84e0c2c74cf1b /src/main | |
parent | 09d90e639bc08db84e1456351a08a896208b026c (diff) | |
download | craftbukkit-c8d77561b16e9edc75b05a10f546ef919a717a92.tar craftbukkit-c8d77561b16e9edc75b05a10f546ef919a717a92.tar.gz craftbukkit-c8d77561b16e9edc75b05a10f546ef919a717a92.tar.lz craftbukkit-c8d77561b16e9edc75b05a10f546ef919a717a92.tar.xz craftbukkit-c8d77561b16e9edc75b05a10f546ef919a717a92.zip |
Added new Server.getPlayerExact() method, added whitelist methods and don't use vanilla commands
Diffstat (limited to 'src/main')
4 files changed, 60 insertions, 56 deletions
diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 956962cd..981f058a 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -42,7 +42,7 @@ public class ServerConfigurationManager { private File l; private File m; public PlayerFileData playerFileData; // CraftBukkit - private - >public - private boolean o; + public boolean o; // Craftbukkit - private -> public // CraftBukkit start private CraftServer cserver; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 1357ac7e..6e5c9c50 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -49,4 +49,16 @@ public class CraftOfflinePlayer implements OfflinePlayer { server.getHandle().b(name.toLowerCase()); } } + + public boolean isWhitelisted() { + return server.getHandle().e().contains(name.toLowerCase()); + } + + public void setWhitelisted(boolean value) { + if (value) { + server.getHandle().k(name.toLowerCase()); + } else { + server.getHandle().l(name.toLowerCase()); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index bb53e4b1..038afed5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -46,9 +46,6 @@ import net.minecraft.server.WorldLoaderServer; import net.minecraft.server.WorldManager; import net.minecraft.server.WorldServer; import net.minecraft.server.ServerCommand; -import net.minecraft.server.ICommandListener; -import net.minecraft.server.Packet; -import net.minecraft.server.Packet3Chat; import net.minecraft.server.Item; import net.minecraft.server.ItemStack; import net.minecraft.server.WorldMap; @@ -66,12 +63,10 @@ import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe; import org.bukkit.craftbukkit.inventory.CraftRecipe; import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; -import org.bukkit.craftbukkit.command.ServerCommandListener; import org.bukkit.craftbukkit.map.CraftMapView; import org.bukkit.scheduler.BukkitWorker; import org.bukkit.craftbukkit.scheduler.CraftScheduler; import org.bukkit.util.permissions.DefaultPermissions; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.world.WorldInitEvent; import org.bukkit.permissions.Permission; import org.bukkit.plugin.PluginLoadOrder; @@ -227,6 +222,18 @@ public final class CraftServer implements Server { return found; } + public Player getPlayerExact(String name) { + String lname = name.toLowerCase(); + + for (Player player : getOnlinePlayers()) { + if (player.getName().equalsIgnoreCase(lname)) { + return player; + } + } + + return null; + } + public int broadcastMessage(String message) { return broadcast(message, BROADCAST_CHANNEL_USERS); } @@ -332,64 +339,17 @@ public final class CraftServer implements Server { // NOTE: Should only be called from MinecraftServer.b() public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) { - if (commandMap.dispatch(sender, serverCommand.command)) { - return true; - } - return console.consoleCommandHandler.handle(serverCommand); + return dispatchCommand(sender, serverCommand.command); } public boolean dispatchCommand(CommandSender sender, String commandLine) { - // CraftBukkit native commands if (commandMap.dispatch(sender, commandLine)) { return true; } - if (sender instanceof Player) { - Player player = (Player)sender; - if (commandLine.toLowerCase().startsWith("me ")) { - if (!player.hasPermission("bukkit.command.me")) { - player.sendMessage(ChatColor.RED + "You do not have permission to perform this command."); - return true; - } - - commandLine = "* " + player.getDisplayName() + " " + commandLine.substring(commandLine.indexOf(" ")).trim(); - server.server.serverConfigurationManager.sendAll(new Packet3Chat(commandLine)); - return true; - } else if (commandLine.toLowerCase().startsWith("kill")) { - if (!player.hasPermission("bukkit.command.kill")) { - player.sendMessage(ChatColor.RED + "You do not have permission to perform this command."); - return true; - } - - EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000); - getPluginManager().callEvent(ede); - if (ede.isCancelled()) return true; - - player.damage(ede.getDamage()); - return true; - } else if (commandLine.toLowerCase().startsWith("tell ")) { - if (!player.hasPermission("bukkit.command.tell")) { - player.sendMessage(ChatColor.RED + "You do not have permission to perform this command."); - return true; - } - - String[] astring = commandLine.split(" "); - - if (astring.length >= 3) { - commandLine = commandLine.substring(commandLine.indexOf(" ")).trim(); - commandLine = commandLine.substring(commandLine.indexOf(" ")).trim(); - commandLine = "\u00A77" + player.getDisplayName() + " whispers " + commandLine; - if (!server.server.serverConfigurationManager.a(astring[1], (Packet) (new Packet3Chat(commandLine)))) { - player.sendMessage(ChatColor.RED + "There's no player by that name online."); - } - } - - return true; - } - } + sender.sendMessage("Unknown command. Type \"help\" for help."); - // See if the server can process this command - return console.consoleCommandHandler.handle(new ServerCommand(commandLine, (ICommandListener) new ServerCommandListener(sender))); + return false; } public void reload() { @@ -839,4 +799,24 @@ public final class CraftServer implements Server { return result; } + + public void setWhitelist(boolean value) { + server.o = value; + console.propertyManager.b("white-list", value); + console.propertyManager.savePropertiesFile(); + } + + public Set<OfflinePlayer> getWhitelistedPlayers() { + Set<OfflinePlayer> result = new HashSet<OfflinePlayer>(); + + for (Object name : server.e()) { + result.add(getOfflinePlayer((String)name)); + } + + return result; + } + + public void reloadWhitelist() { + server.f(); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index f587f3b3..4a1fa601 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -366,4 +366,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { server.getHandle().b(getName().toLowerCase()); } } + + public boolean isWhitelisted() { + return server.getHandle().e().contains(getName().toLowerCase()); + } + + public void setWhitelisted(boolean value) { + if (value) { + server.getHandle().k(getName().toLowerCase()); + } else { + server.getHandle().l(getName().toLowerCase()); + } + } } |