use of org.bukkit.OfflinePlayer in project Prism-Bukkit by prism.
the class EntityAction method applyRollback.
/**
*
*/
@Override
public ChangeResult applyRollback(Player player, QueryParameters parameters, boolean is_preview) {
if (getEntityType() == null) {
return new ChangeResult(ChangeResultType.SKIPPED, null);
}
if (Prism.getIllegalEntities().contains(getEntityType().name().toLowerCase())) {
return new ChangeResult(ChangeResultType.SKIPPED, null);
}
if (!is_preview) {
final Location loc = getLoc();
loc.setX(loc.getX() + 0.5);
loc.setZ(loc.getZ() + 0.5);
final Entity entity = loc.getWorld().spawnEntity(loc, getEntityType());
// Get custom name
if (entity instanceof LivingEntity && getCustomName() != null) {
final LivingEntity namedEntity = (LivingEntity) entity;
namedEntity.setCustomName(getCustomName());
}
// Get animal age
if (entity instanceof Ageable) {
final Ageable age = (Ageable) entity;
if (!isAdult()) {
age.setBaby();
} else {
age.setAdult();
}
}
// Set sheep color
if (entity.getType().equals(EntityType.SHEEP) && getColor() != null) {
final Sheep sheep = ((Sheep) entity);
sheep.setColor(getColor());
}
// Set villager profession
if (entity instanceof Villager && getProfession() != null) {
final Villager v = (Villager) entity;
v.setProfession(getProfession());
}
// Set wolf details
if (entity instanceof Wolf) {
// Owner
final Wolf wolf = (Wolf) entity;
final String tamingOwner = getTamingOwner();
if (tamingOwner != null) {
Player owner = plugin.getServer().getPlayer(tamingOwner);
if (owner == null) {
final OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(tamingOwner);
if (offlinePlayer.hasPlayedBefore()) {
owner = offlinePlayer.getPlayer();
}
}
if (owner != null)
wolf.setOwner(owner);
}
// Collar color
if (getColor() != null) {
wolf.setCollarColor(getColor());
}
if (isSitting()) {
wolf.setSitting(true);
}
}
// Set ocelot details
if (entity instanceof Ocelot) {
// Owner
final Ocelot ocelot = (Ocelot) entity;
final String tamingOwner = getTamingOwner();
if (tamingOwner != null) {
Player owner = plugin.getServer().getPlayer(tamingOwner);
if (owner == null) {
final OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(tamingOwner);
if (offlinePlayer.hasPlayedBefore()) {
owner = offlinePlayer.getPlayer();
}
}
if (owner != null) {
ocelot.setOwner(owner);
}
}
// Cat type
if (getCatType() != null) {
ocelot.setCatType(getCatType());
}
// Sitting
if (isSitting()) {
ocelot.setSitting(true);
}
}
// Set horse details
if (entity instanceof Horse) {
final Horse h = (Horse) entity;
if (getVariant() != null) {
h.setVariant(getVariant());
}
if (getHorseColor() != null) {
h.setColor(getHorseColor());
}
if (getStyle() != null) {
h.setStyle(getStyle());
}
h.setCarryingChest(this.actionData.chest);
h.setDomestication(this.actionData.dom);
h.setMaxDomestication(this.actionData.maxDom);
h.setJumpStrength(this.actionData.jump);
h.setMaxHealth(this.actionData.maxHealth);
// Stuff
h.getInventory().setSaddle(getSaddle());
h.getInventory().setArmor(getArmor());
// Owner
final String tamingOwner = getTamingOwner();
if (tamingOwner != null) {
Player owner = plugin.getServer().getPlayer(tamingOwner);
if (owner == null) {
final OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(tamingOwner);
if (offlinePlayer.hasPlayedBefore()) {
owner = offlinePlayer.getPlayer();
}
}
if (owner != null)
h.setOwner(owner);
}
}
return new ChangeResult(ChangeResultType.APPLIED, null);
}
return new ChangeResult(ChangeResultType.PLANNED, null);
}
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 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");
}
}
Aggregations