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()]));
}
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");
}
}
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);
}
}
}
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);
}
}
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;
}
Aggregations