Search in sources :

Example 26 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project AuthMeReloaded by AuthMe.

the class PurgeBannedPlayersCommand method executeCommand.

@Override
public void executeCommand(CommandSender sender, List<String> arguments) {
    // Get the list of banned players
    Set<OfflinePlayer> bannedPlayers = bukkitService.getBannedPlayers();
    Set<String> namedBanned = new HashSet<>(bannedPlayers.size());
    for (OfflinePlayer offlinePlayer : bannedPlayers) {
        namedBanned.add(offlinePlayer.getName().toLowerCase());
    }
    purgeService.purgePlayers(sender, namedBanned, bannedPlayers.toArray(new OfflinePlayer[bannedPlayers.size()]));
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer) HashSet(java.util.HashSet)

Example 27 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project AuthMeReloaded by AuthMe.

the class PurgePlayerCommand method executeCommand.

private void executeCommand(CommandSender sender, String name, String option) {
    if ("force".equals(option) || !dataSource.isAuthAvailable(name)) {
        OfflinePlayer offlinePlayer = bukkitService.getOfflinePlayer(name);
        purgeExecutor.executePurge(singletonList(offlinePlayer), singletonList(name.toLowerCase()));
        sender.sendMessage("Purged data for player " + name);
    } else {
        sender.sendMessage("This player is still registered! Are you sure you want to proceed? " + "Use '/authme purgeplayer " + name + " force' to run the command anyway");
    }
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer)

Example 28 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project AuthMeReloaded by AuthMe.

the class RoyalAuthConverter method execute.

@Override
public void execute(CommandSender sender) {
    for (OfflinePlayer player : plugin.getServer().getOfflinePlayers()) {
        try {
            String name = player.getName().toLowerCase();
            File file = new File(makePath(".", "plugins", "RoyalAuth", "userdata", name + ".yml"));
            if (dataSource.isAuthAvailable(name) || !file.exists()) {
                continue;
            }
            FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
            PlayerAuth auth = PlayerAuth.builder().name(name).password(configuration.getString(PASSWORD_PATH), null).lastLogin(configuration.getLong(LAST_LOGIN_PATH)).realName(player.getName()).build();
            dataSource.saveAuth(auth);
        } catch (Exception e) {
            ConsoleLogger.logException("Error while trying to import " + player.getName() + " RoyalAuth data", e);
        }
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) OfflinePlayer(org.bukkit.OfflinePlayer) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) File(java.io.File)

Example 29 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project AuthMeReloaded by AuthMe.

the class HasPermissionChecker method execute.

@Override
public void execute(CommandSender sender, List<String> arguments) {
    if (arguments.size() < 2) {
        sender.sendMessage("Check if a player has permission:");
        sender.sendMessage("Example: /authme debug perm bobby my.perm.node");
        return;
    }
    final String playerName = arguments.get(0);
    final String permissionNode = arguments.get(1);
    Player player = bukkitService.getPlayerExact(playerName);
    if (player == null) {
        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
        if (offlinePlayer == null) {
            sender.sendMessage(ChatColor.DARK_RED + "Player '" + playerName + "' does not exist");
        } else {
            sender.sendMessage("Player '" + playerName + "' not online; checking with offline player");
            performPermissionCheck(offlinePlayer, permissionNode, permissionsManager::hasPermissionOffline, sender);
        }
    } else {
        performPermissionCheck(player, permissionNode, permissionsManager::hasPermission, sender);
    }
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) OfflinePlayer(org.bukkit.OfflinePlayer)

Example 30 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project Glowstone by GlowstoneMC.

the class GlowBanEntry method write.

@Override
public Map<String, String> write() {
    Map<String, String> result = new LinkedHashMap<>();
    // target
    if (list.type == Type.NAME) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(target);
        result.put("uuid", player.getUniqueId().toString());
        result.put("name", player.getName());
    } else if (list.type == Type.IP) {
        result.put("ip", target);
    }
    // other data
    result.put("created", GlowBanList.DATE_FORMAT.format(created));
    result.put("source", source);
    result.put("expires", expires == null ? GlowBanList.FOREVER : GlowBanList.DATE_FORMAT.format(expires));
    result.put("reason", reason);
    return result;
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

OfflinePlayer (org.bukkit.OfflinePlayer)55 Player (org.bukkit.entity.Player)21 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)10 Job (com.gamingmesh.jobs.container.Job)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 ArrayList (java.util.ArrayList)6 File (java.io.File)5 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 World (org.bukkit.World)4 CommandSender (org.bukkit.command.CommandSender)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 UUID (java.util.UUID)3 Location (org.bukkit.Location)3 JobProgression (com.gamingmesh.jobs.container.JobProgression)2 Island (com.wasteofplastic.acidisland.Island)2 List (java.util.List)2 Set (java.util.Set)2 net.aufdemrand.denizen.objects.dWorld (net.aufdemrand.denizen.objects.dWorld)2