Author: ATracer
(2010/03/14 21:35) Almost 2 years ago
Improved Add admin command + Remove, thx lyahim
152
# Legion command allows you to disband/setlevel/setpoints of a legion
153
gameserver.administration.command.legion = 3
154
155
# Remove command allow remove an item from player
156
gameserver.administration.command.remove = 3
157
# Prison command
158
gameserver.administration.command.prison = 3
159
20
import com.aionemu.gameserver.model.gameobjects.player.Player;
21
import com.aionemu.gameserver.services.ItemService;
22
import com.aionemu.gameserver.utils.PacketSendUtility;
23
import com.aionemu.gameserver.utils.Util;
import com.aionemu.gameserver.utils.chathandlers.AdminCommand;
24
25
import com.aionemu.gameserver.world.World;
import com.google.inject.Inject;
26
27
/**
28
...
32
{
34
33
@Inject
35
private ItemService itemService;
36
37
38
private World world;
39
public Add()
40
41
super("add");
42
47
return;
51
48
}
52
49
53
50
if(params.length == 0 || params.length > 2)
54
if(params.length == 0 || params.length > 3)
55
PacketSendUtility.sendMessage(admin, "syntax //add <item ID> <quantity>");
56
PacketSendUtility.sendMessage(admin, "syntax //add <player> <item ID> <quantity>");
57
58
59
int itemId = 0;
60
int itemCount = 1;
61
62
Player receiver = null;
63
try
64
65
itemId = Integer.parseInt(params[0]);
66
67
if( params.length == 2 )
68
69
itemCount = Integer.parseInt(params[1]);
70
71
72
receiver = admin;
73
catch (NumberFormatException e)
74
75
PacketSendUtility.sendMessage(admin, "Parameters need to be an integer.");
76
receiver = world.findPlayer(Util.convertName(params[0]));
77
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
91
92
catch (Exception ex2)
93
94
PacketSendUtility.sendMessage(admin, "Occurs an error.");
95
96
97
98
int count = itemService.addItem(admin, itemId, itemCount, false);
99
int count = itemService.addItem(receiver, itemId, itemCount, false);
100
if(count == 0)
101
102
PacketSendUtility.sendMessage(admin, "Item added successfully");
103
104
PacketSendUtility.sendMessage(receiver, "Admin gives you an item");
105
else
106
107
PacketSendUtility.sendMessage(admin, "Item couldn't be added");
108
109
110
111
112
146
@Property(key = "gameserver.administration.command.legion", defaultValue = "3")
147
public static int COMMAND_LEGION;
148
149
@Property(key = "gameserver.administration.command.remove", defaultValue = "3")
150
public static int COMMAND_REMOVE;
151
@Property(key = "gameserver.administration.command.prison", defaultValue = "3")
public static int COMMAND_PRISON;
243
setPersistentState(PersistentState.UPDATE_REQUIRED);
244
return result;
245
246
247
*
248
* @param itemId
249
* @return Item
250
*/
251
public Item getFirstItemByItemId(int itemId)
252
253
List<Item> items = storage.getItemsFromStorageByItemId(itemId);
254
return items.get(0);
255
256
* Used to reduce item count in bag or completely remove by OBJECTID
257
* Return value can be the following:
258
* - true - item removal was successfull
259
{{@Injectprivate World world;{{super("add");super("add");if(params.length == 0 || params.length > 2)if(params.length == 0 || params.length > 3){{PacketSendUtility.sendMessage(admin, "syntax //add <player> <item ID> <quantity>");{{{{{{PacketSendUtility.sendMessage(admin, "Parameters need to be an integer.");receiver = world.findPlayer(Util.convertName(params[0]));return;try{itemId = Integer.parseInt(params[1]);if( params.length == 3 ){itemCount = Integer.parseInt(params[2]);}}catch (NumberFormatException ex){PacketSendUtility.sendMessage(admin, "You must give number to itemid.");return;}catch (Exception ex2){PacketSendUtility.sendMessage(admin, "Occurs an error.");return;}int count = itemService.addItem(admin, itemId, itemCount, false);int count = itemService.addItem(receiver, itemId, itemCount, false);{{{{{