Skip to content

Commit

Permalink
Fetch player asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Apr 17, 2022
1 parent 18d1344 commit 065f2d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public void execute(@NotNull CommandSender sender, @NotNull String[] args) {
sender.sendMessage(ChatColor.RED + "Usage: " + getFullUsage());
return;
}
Player target = PlayerUtil.getOfflinePlayer(args[0]);
boolean res = Protocol.P_GIVE_GAMING_SARA.sendPacket(SpigotPlugin.getAnyPacketSenderOrNull(), new PlayerMessage(target));
if (res) {
sender.sendMessage(ChatColor.GREEN + "Sent a request to give " + target.getUsername() + " the gaming sara");
} else {
sender.sendMessage(ChatColor.RED + "Failed to send the packet (attempted to give " + target.getUsernameOrUniqueId() + " the gaming sara). Maybe check console for errors?");
}
new Thread(() -> {
Player target = PlayerUtil.getOfflinePlayer(args[0]);
boolean res = Protocol.P_GIVE_GAMING_SARA.sendPacket(SpigotPlugin.getAnyPacketSenderOrNull(), new PlayerMessage(target));
if (res) {
sender.sendMessage(ChatColor.GREEN + "Sent a request to give " + target.getUsername() + " the gaming sara");
} else {
sender.sendMessage(ChatColor.RED + "Failed to send the packet (attempted to give " + target.getUsernameOrUniqueId() + " the gaming sara). Maybe check console for errors?");
}
}).start();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public void execute(@NotNull CommandSender sender, @NotNull String[] args) {
return;
}
int amount = Integer.parseInt(args[0]);
Player target = PlayerUtil.getOfflinePlayer(args[1]);
boolean res = Protocol.P_GIVE_SARA.sendPacket(SpigotPlugin.getAnyPacketSenderOrNull(), new ProxyboundGiveSaraMessage(amount, target));
if (res) {
sender.sendMessage(ChatColor.GREEN + "Sent a request to give " + target.getUsername() + " the " + amount + "yen sara");
} else {
sender.sendMessage(ChatColor.RED + "Failed to send the packet (attempted to give " + target.getUsernameOrUniqueId() + " the " + amount + "yen sara). Maybe check console for errors?");
}
new Thread(() -> {
Player target = PlayerUtil.getOfflinePlayer(args[1]);
boolean res = Protocol.P_GIVE_SARA.sendPacket(SpigotPlugin.getAnyPacketSenderOrNull(), new ProxyboundGiveSaraMessage(amount, target));
if (res) {
sender.sendMessage(ChatColor.GREEN + "Sent a request to give " + target.getUsername() + " the " + amount + "yen sara");
} else {
sender.sendMessage(ChatColor.RED + "Failed to send the packet (attempted to give " + target.getUsernameOrUniqueId() + " the " + amount + "yen sara). Maybe check console for errors?");
}
}).start();
}

@Override
Expand Down

0 comments on commit 065f2d5

Please sign in to comment.