Changeset 1525

User picture

Author: ATracer

(2010/03/14 21:35) Almost 2 years ago

Improved Add admin command + Remove, thx lyahim

Affected files

Updated trunk/AE-go_GameServer/config/administration/admin.properties Download diff

15241525
152
# Legion command allows you to disband/setlevel/setpoints of a legion
152
# Legion command allows you to disband/setlevel/setpoints of a legion
153
gameserver.administration.command.legion = 3
153
gameserver.administration.command.legion = 3
154
154
155
# Remove command allow remove an item from player
156
gameserver.administration.command.remove = 3
157
155
# Prison command
158
# Prison command
156
gameserver.administration.command.prison = 3
159
gameserver.administration.command.prison = 3

Updated trunk/AE-go_GameServer/data/scripts/system/handlers/admincommands/Add.java Download diff

15241525
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
}

Added trunk/AE-go_GameServer/data/scripts/system/handlers/admincommands/Remove.java

Show contents

Updated trunk/AE-go_GameServer/src/com/aionemu/gameserver/configs/administration/AdminConfig.java Download diff

15241525
146
	@Property(key = "gameserver.administration.command.legion", defaultValue = "3")
146
	@Property(key = "gameserver.administration.command.legion", defaultValue = "3")
147
	public static int	COMMAND_LEGION;
147
	public static int	COMMAND_LEGION;
148
148
149
    @Property(key = "gameserver.administration.command.remove", defaultValue = "3")
150
    public static int	COMMAND_REMOVE;
151
    
149
	@Property(key = "gameserver.administration.command.prison", defaultValue = "3")
152
	@Property(key = "gameserver.administration.command.prison", defaultValue = "3")
150
	public static int	COMMAND_PRISON;
153
	public static int	COMMAND_PRISON;
154
151
}
155
}

Updated trunk/AE-go_GameServer/src/com/aionemu/gameserver/model/gameobjects/player/Storage.java Download diff

15241525
243
			setPersistentState(PersistentState.UPDATE_REQUIRED);
243
			setPersistentState(PersistentState.UPDATE_REQUIRED);
244
		return result;
244
		return result;
245
	}
245
	}
246
247
	/**
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
	/**
248
	 *  Used to reduce item count in bag or completely remove by OBJECTID
257
	 *  Used to reduce item count in bag or completely remove by OBJECTID
249
	 *  Return value can be the following:
258
	 *  Return value can be the following:
250
	 *  - true - item removal was successfull
259
	 *  - true - item removal was successfull