Skip to content

Commit

Permalink
Merge pull request #206 from pavog/fix-exception-in-bukkit-1-20
Browse files Browse the repository at this point in the history
Fix exception in Bukkit 1.20 on command "/money give" from console
  • Loading branch information
pavog authored Jul 26, 2023
2 parents 659ebbd + 6f822a9 commit 1792716
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public BukkitPlayerCaller(ServerCaller caller) {


private Player getBukkitPlayer(UUID uuid) {
if (uuid == null) {
return null;
}
return ((BukkitLoader) getCaller().getLoader()).getServer().getPlayer(uuid);

}
Expand Down Expand Up @@ -139,7 +142,7 @@ public String getPlayerWorld(String playerName) {

@Override
public String getPlayerWorld(UUID uuid) {
Player p = ((BukkitLoader) getCaller().getLoader()).getServer().getPlayer(uuid);
Player p = this.getBukkitPlayer(uuid);
return (p != null) ? p.getWorld().getName() : "";
}

Expand All @@ -151,7 +154,7 @@ public boolean isOnline(String playerName) {

@Override
public boolean isOnline(UUID uuid) {
return ((BukkitLoader) getCaller().getLoader()).getServer().getPlayer(uuid) != null;
return this.getBukkitPlayer(uuid) != null;
}

@Override
Expand Down Expand Up @@ -209,7 +212,7 @@ public String getPlayerName(UUID uuid) {

@Override
public com.greatmancode.craftconomy3.tools.entities.Player getPlayer(UUID uuid) {
Player player = ((BukkitLoader) getCaller().getLoader()).getServer().getPlayer(uuid);
Player player = this.getBukkitPlayer(uuid);
if (player == null) return null;
CommandSender sender = new PlayerCommandSender<>(player.getDisplayName(), player.getUniqueId(), player);
return new com.greatmancode.craftconomy3.tools.entities.Player(player.getName(),
Expand All @@ -231,7 +234,7 @@ public com.greatmancode.craftconomy3.tools.entities.Player getOnlinePlayer(Strin

@Override
public com.greatmancode.craftconomy3.tools.entities.Player getOnlinePlayer(UUID uuid) {
Player player = ((BukkitLoader) getCaller().getLoader()).getServer().getPlayer(uuid);
Player player = this.getBukkitPlayer(uuid);
if (player == null) return null;
if (player.isOnline()) {
CommandSender sender = new PlayerCommandSender<>(player.getDisplayName(), player.getUniqueId(), player);
Expand Down

0 comments on commit 1792716

Please sign in to comment.