root/trunk/AE-go_GameServer/data/scripts/system/handlers/admincommands/Add.java
| 1460 | 1525 | ||
|---|---|---|---|
20 | import com.aionemu.gameserver.model.gameobjects.player.Player; | 20 | import com.aionemu.gameserver.model.gameobjects.player.Player; |
21 | import com.aionemu.gameserver.services.ItemService; | 21 | import com.aionemu.gameserver.services.ItemService; |
22 | import com.aionemu.gameserver.utils.PacketSendUtility; | 22 | import com.aionemu.gameserver.utils.PacketSendUtility; |
23 | import com.aionemu.gameserver.utils.Util; | ||
23 | import com.aionemu.gameserver.utils.chathandlers.AdminCommand; | 24 | import com.aionemu.gameserver.utils.chathandlers.AdminCommand; |
25 | import com.aionemu.gameserver.world.World; | ||
24 | import com.google.inject.Inject; | 26 | import com.google.inject.Inject; |
25 | 27 | ||
26 | /** | 28 | /** |
... | ... | ||
32 | { | 34 | { |
33 | @Inject | 35 | @Inject |
34 | private ItemService itemService; | 36 | private ItemService itemService; |
35 | 37 | @Inject | |
38 | private World world; | ||
39 | | ||
36 | public Add() | 40 | public Add() |
37 | { | 41 | { |
38 | super("add"); | 42 | super("add"); |
... | ... | ||
47 | return; | 51 | return; |
48 | } | 52 | } |
49 | 53 | ||
50 | if(params.length == 0 || params.length > 2) | 54 | if(params.length == 0 || params.length > 3) |
51 | { | 55 | { |
52 | PacketSendUtility.sendMessage(admin, "syntax //add <item ID> <quantity>"); | 56 | PacketSendUtility.sendMessage(admin, "syntax //add <player> <item ID> <quantity>"); |
53 | return; | 57 | return; |
54 | } | 58 | } |
55 | 59 | ||
56 | int itemId = 0; | 60 | int itemId = 0; |
57 | int itemCount = 1; | 61 | int itemCount = 1; |
62 | Player receiver = null; | ||
58 | 63 | ||
59 | try | 64 | try |
60 | { | 65 | { |
61 | itemId = Integer.parseInt(params[0]); | 66 | itemId = Integer.parseInt(params[0]); |
67 | |||
62 | if( params.length == 2 ) | 68 | if( params.length == 2 ) |
63 | { | 69 | { |
64 | itemCount = Integer.parseInt(params[1]); | 70 | itemCount = Integer.parseInt(params[1]); |
65 | } | 71 | } |
72 | receiver = admin; | ||
66 | } | 73 | } |
67 | catch (NumberFormatException e) | 74 | catch (NumberFormatException e) |
68 | { | 75 | { |
69 | PacketSendUtility.sendMessage(admin, "Parameters need to be an integer."); | 76 | receiver = world.findPlayer(Util.convertName(params[0])); |
70 | return; | 77 | try |
78 | { | ||
79 | itemId = Integer.parseInt(params[1]); | ||
80 | | ||
81 | if( params.length == 3 ) | ||
82 | { | ||
83 | itemCount = Integer.parseInt(params[2]); | ||
84 | } | ||
85 | } | ||
86 | catch (NumberFormatException ex) | ||
87 | { | ||
88 | | ||
89 | PacketSendUtility.sendMessage(admin, "You must give number to itemid."); | ||
90 | return; | ||
91 | } | ||
92 | catch (Exception ex2) | ||
93 | { | ||
94 | PacketSendUtility.sendMessage(admin, "Occurs an error."); | ||
95 | return; | ||
96 | } | ||
71 | } | 97 | } |
72 | 98 | ||
73 | int count = itemService.addItem(admin, itemId, itemCount, false); | 99 | int count = itemService.addItem(receiver, itemId, itemCount, false); |
74 | 100 | ||
75 | if(count == 0) | 101 | if(count == 0) |
76 | { | 102 | { |
77 | PacketSendUtility.sendMessage(admin, "Item added successfully"); | 103 | PacketSendUtility.sendMessage(admin, "Item added successfully"); |
104 | PacketSendUtility.sendMessage(receiver, "Admin gives you an item"); | ||
78 | } | 105 | } |
79 | else | 106 | else |
80 | { | 107 | { |
81 | PacketSendUtility.sendMessage(admin, "Item couldn't be added"); | 108 | PacketSendUtility.sendMessage(admin, "Item couldn't be added"); |
82 | } | 109 | } |
110 | |||
83 | } | 111 | } |
84 | } | 112 | } |
Download diff