So I am redoing the /deop and /op commands so it 'fits' with my server style and I can add my own permissions, etc, blah. blah. I know getOfflinePlayer() is depreciated, but is there another way to get the player who is offline? At the moment I'm doing this: Code (Text): @SuppressWarnings("deprecation") Player checkOfflinePlayer = (Player) Bukkit.getOfflinePlayer(args[0]); if (checkOfflinePlayer.hasPlayedBefore()) { if (checkOfflinePlayer.isOp()) { checkOfflinePlayer.setOp(false); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You have deoped " + checkOfflinePlayer.getName() + " who is offline")); } else { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7" + checkOfflinePlayer.getName() + " is not an operator")); } } else { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7" + args[0] + " has never played before!")); } However, this is the console error: Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_9_R1.CraftOfflinePlayer cannot be cast to org.bukkit.entity.Player at test.moderance.commands.DeOp.onCommand(DeOp.java:41) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-e6f93f4-ed60c01] ... 15 more Line 41: Code (Text): Player checkOfflinePlayer = (Player) Bukkit.getOfflinePlayer(args[0]); Thank you for any help given.
You're casting an OfflinePlayer to a Player. Of course it will throw an error. Remove the cast and try it.
The Server class provides the method #getOperators() that returns as Set<OfflinePlayer> this might help you out. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#getOperators()
OHH.. I'm so stupid, thanks! Solved Code (Text): OfflinePlayer checkOfflinePlayer = Bukkit.getOfflinePlayer(args[0]); Another Question: This is going to the else instead of passing through as equals, even though the uuid is matching the checkPlayer public String uuid = "069a79f4-44e9-4726-a5be-fca90e38aaf5"; if (checkPlayer.getUniqueId().equals(uuid)) { //is player } else { //not player }