use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method fire.
@JobCommand
public boolean fire(CommandSender sender, String[] args) {
if (args.length < 2) {
sendUsage(sender, "fire");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (!jPlayer.isInJob(job)) {
String message = ChatColor.RED + Language.getMessage("command.fire.error.nojob");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
sender.sendMessage(message);
return true;
}
try {
Jobs.getPlayerManager().leaveJob(jPlayer, job);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.fire.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method removexp.
@JobCommand
public boolean removexp(CommandSender sender, String[] args) {
if (args.length < 3) {
sendUsage(sender, "removexp");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
double xpLost;
try {
xpLost = Double.parseDouble(args[2]);
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
return true;
}
if (xpLost <= 0) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
return true;
}
// check if player already has the job
if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.removexp.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
message = message.replace("%xplost%", Double.valueOf(xpLost).toString());
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
}
return true;
}
use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method employ.
@JobCommand
public boolean employ(CommandSender sender, String[] args) {
if (args.length < 2) {
sendUsage(sender, "employ");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
String message = ChatColor.RED + Language.getMessage("command.employ.error.alreadyin");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
sender.sendMessage(message);
return true;
}
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.employ.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of org.bukkit.OfflinePlayer in project AuthMeReloaded by AuthMe.
the class PurgeTask method run.
@Override
public void run() {
if (toPurge.isEmpty()) {
//everything was removed
finish();
return;
}
Set<OfflinePlayer> playerPortion = new HashSet<>(INTERVAL_CHECK);
Set<String> namePortion = new HashSet<>(INTERVAL_CHECK);
for (int i = 0; i < INTERVAL_CHECK; i++) {
int nextPosition = (currentPage * INTERVAL_CHECK) + i;
if (offlinePlayers.length <= nextPosition) {
//no more offline players on this page
break;
}
OfflinePlayer offlinePlayer = offlinePlayers[nextPosition];
if (offlinePlayer.getName() != null && toPurge.remove(offlinePlayer.getName().toLowerCase())) {
if (!permissionsManager.hasPermissionOffline(offlinePlayer, PlayerStatePermission.BYPASS_PURGE)) {
playerPortion.add(offlinePlayer);
namePortion.add(offlinePlayer.getName());
}
}
}
if (!toPurge.isEmpty() && playerPortion.isEmpty()) {
ConsoleLogger.info("Finished lookup of offlinePlayers. Begin looking purging player names only");
//we went through all offlineplayers but there are still names remaining
for (String name : toPurge) {
if (!permissionsManager.hasPermissionOffline(name, PlayerStatePermission.BYPASS_PURGE)) {
namePortion.add(name);
}
}
toPurge.clear();
}
currentPage++;
purgeService.executePurge(playerPortion, namePortion);
if (currentPage % 20 == 0) {
int completed = totalPurgeCount - toPurge.size();
sendMessage("[AuthMe] Purge progress " + completed + '/' + totalPurgeCount);
}
}
use of org.bukkit.OfflinePlayer in project AuthMeReloaded by AuthMe.
the class PurgeExecutor method purgeDat.
/**
* Removes the .dat file of the given players.
*
* @param cleared list of players to clear
*/
synchronized void purgeDat(Collection<OfflinePlayer> cleared) {
if (!settings.getProperty(PurgeSettings.REMOVE_PLAYER_DAT)) {
return;
}
int i = 0;
File dataFolder = new File(server.getWorldContainer(), makePath(settings.getProperty(PurgeSettings.DEFAULT_WORLD), "players"));
for (OfflinePlayer offlinePlayer : cleared) {
File playerFile = new File(dataFolder, PlayerUtils.getUuidOrName(offlinePlayer) + ".dat");
if (playerFile.delete()) {
i++;
}
}
ConsoleLogger.info("AutoPurge: Removed " + i + " .dat Files");
}
Aggregations