@@ -0,0 +1,3318 @@
+*%0A * Copyright 2011 Sebastian K%C3%B6hler %3Csebkoehler@whoami.org.uk%3E.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage uk.org.whoami.authme.commands;%0A%0Aimport java.security.NoSuchAlgorithmException;%0A%0Aimport org.bukkit.command.Command;%0Aimport org.bukkit.command.CommandExecutor;%0Aimport org.bukkit.command.CommandSender;%0Aimport org.bukkit.entity.Player;%0A%0Aimport uk.org.whoami.authme.ConsoleLogger;%0Aimport uk.org.whoami.authme.cache.auth.PlayerAuth;%0Aimport uk.org.whoami.authme.cache.auth.PlayerCache;%0Aimport uk.org.whoami.authme.datasource.DataSource;%0Aimport uk.org.whoami.authme.security.PasswordSecurity;%0Aimport uk.org.whoami.authme.settings.Messages;%0Aimport uk.org.whoami.authme.settings.Settings;%0A%0Apublic class ChangePasswordCommand implements CommandExecutor %7B%0A%0A    private Messages m = Messages.getInstance();%0A    private Settings settings = Settings.getInstance();%0A    private DataSource database;%0A%0A    public ChangePasswordCommand(DataSource database) %7B%0A        this.database = database;%0A    %7D%0A%0A    @Override%0A    public boolean onCommand(CommandSender sender, Command cmnd, String label, String%5B%5D args) %7B%0A        if (!(sender instanceof Player)) %7B%0A            return true;%0A        %7D%0A%0A        if (!sender.hasPermission(%22authme.%22 + label.toLowerCase())) %7B%0A            sender.sendMessage(m._(%22no_perm%22));%0A            return true;%0A        %7D%0A%0A        Player player = (Player) sender;%0A        String name = player.getName().toLowerCase();%0A        String ip = player.getAddress().getAddress().getHostAddress();%0A%0A        if (!PlayerCache.getInstance().isAuthenticated(name)) %7B%0A            player.sendMessage(m._(%22not_logged_in%22));%0A            return true;%0A        %7D%0A%0A        if (args.length != 2) %7B%0A            player.sendMessage(m._(%22Usage: /changepassword oldPassword newPassword%22));%0A            return true;%0A        %7D%0A%0A        try %7B%0A            String hashnew = PasswordSecurity.getHash(settings.getPasswordHash(), args%5B1%5D);%0A%0A            if (PasswordSecurity.comparePasswordWithHash(args%5B0%5D, PlayerCache.getInstance().getAuth(name).getHash())) %7B%0A                PlayerAuth auth = PlayerCache.getInstance().getAuth(name);%0A                auth.setHash(hashnew);%0A                if (!database.updatePassword(auth)) %7B%0A                    player.sendMessage(m._(%22error%22));%0A                    return true;%0A                %7D%0A                PlayerCache.getInstance().updatePlayer(auth);%0A                player.sendMessage(m._(%22pwd_changed%22));%0A                ConsoleLogger.info(player.getDisplayName() + %22 changed his password%22);%0A            %7D else %7B%0A                player.sendMessage(m._(%22wrong_pwd%22));%0A            %7D%0A        %7D catch (NoSuchAlgorithmException ex) %7B%0A            ConsoleLogger.showError(ex.getMessage());%0A            sender.sendMessage(m._(%22error%22));%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A

Create ChangePasswordCommand.java