Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Commit

Permalink
Send items directly to online players
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeo committed Apr 21, 2013
1 parent 8fef1f8 commit 2c750f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
@@ -1,5 +1,5 @@
name: OfflineGive
version: 1.0.0.1
version: 1.0.1.0
author: Celeo
website: http://www.darktidegames.com/
descriptions: Allows a player to receive items when they next login
Expand Down
23 changes: 21 additions & 2 deletions src/com/darktidegames/celeo/offlinegive/OfflineGive.java
Expand Up @@ -165,8 +165,27 @@ else if (sender instanceof Player)
return false;
add.setDurability((short) i(args[3]));
}
addPending(args[0], add);
sendMessage(sender, String.format("§a%s §ewill recieve §a%s §eof §a%s §enext login.", args[0], args[2], args[1]));
Player online = getServer().getPlayer(args[0]);
if (online != null)
{
if (PendingItem.getSpace(online.getInventory().getContents(), add.getTypeId()) >= add.getAmount())
{
online.getInventory().addItem(add);
sendMessage(sender, "§eItems given directly to §a"
+ online.getName() + "§e, as they are online now");
}
else
{
addPending(args[0], add);
sendMessage(sender, String.format("§a%s §edoes not have inventory room, but is online. They will recieve §a%s §eof §a%s §enext login.", args[0], args[2], args[1]));
online.sendMessage("");
}
}
else
{
addPending(args[0], add);
sendMessage(sender, String.format("§a%s §ewill recieve §a%s §eof §a%s §enext login.", args[0], args[2], args[1]));
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/com/darktidegames/celeo/offlinegive/PendingItem.java
Expand Up @@ -151,7 +151,7 @@ public void transfer(Player player)
* int
* @return int
*/
public int getSpace(ItemStack[] contents, int typeId)
public static int getSpace(ItemStack[] contents, int typeId)
{
int count = 0;
ItemStack addItem = new ItemStack(typeId, 1);
Expand Down

0 comments on commit 2c750f2

Please sign in to comment.