View difference between Paste ID: gNipjizr and NPC1C9hf
SHOW: | | - or go back to the newest paste.
1
=============================================
2
Index: Config.java
3
=============================================
4
	
5
	/** Geodata */
6
	public static String GEODATA_PATH;
7
	public static GeoType GEODATA_TYPE;
8
	
9
+	public static boolean ENABLE_LUCKBOX;
10
+	public static int LUCKBOXITEMUSEID;
11
+	public static List<RewardHolder> LUCKBOXLIST01 = new ArrayList<>();
12
+	public static List<RewardHolder> LUCKBOXLIST02 = new ArrayList<>();
13
+	public static List<RewardHolder> LUCKBOXLIST03 = new ArrayList<>();
14
+	public static List<RewardHolder> LUCKBOXLIST04 = new ArrayList<>();
15
+	public static List<RewardHolder> LUCKBOXLIST05 = new ArrayList<>();
16
17
	public static final String GEOENGINE_FILE = "./config/geoengine.properties";
18
+	public static final String ItemHandler_FILE = "./config/Dev/ItemHandler.properties";
19
	
20
+	/**
21
+	 * Loads All ItemsHandler settings.
22
+	 */
23
+	private static final void loadItemsHandler()
24
+	{
25
+		final ExProperties ItemsHandler = initProperties(ItemHandler_FILE);
26
+		
27
+		ENABLE_LUCKBOX = ItemsHandler.getProperty("EnableLuckBox", true);
28
+		LUCKBOXITEMUSEID = Integer.parseInt(ItemsHandler.getProperty("LuckBoxItemUseId", "3"));
29
+		LUCKBOXLIST01 = parseReward(ItemsHandler, "LuckboxRewardList01");
30
+		LUCKBOXLIST02 = parseReward(ItemsHandler, "LuckboxRewardList02");
31
+		LUCKBOXLIST03 = parseReward(ItemsHandler, "LuckboxRewardList03");
32
+		LUCKBOXLIST04 = parseReward(ItemsHandler, "LuckboxRewardList04");
33
+		LUCKBOXLIST05 = parseReward(ItemsHandler, "LuckboxRewardList05");
34
+		
35
+	}
36
37
38
		// geoengine settings
39
		loadGeoengine();
40
		
41
+		loadItemsHandler;
42
43
+	private static List<RewardHolder> parseReward(ExProperties propertie, String configName)
44
+	{
45
+		List<RewardHolder> auxReturn = new ArrayList<>();
46
+		
47
+		String aux = propertie.getProperty(configName).trim();
48
+		for (String randomReward : aux.split(";"))
49
+		{
50
+			final String[] infos = randomReward.split(",");
51
+			if (infos.length > 2)
52
+				auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2])));
53
+			else
54
+				auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1])));
55
+		}
56
+		return auxReturn;
57
+	}
58
59
}
60
61
62
=============================================
63
Index: RewardHolder.java
64
=============================================
65
+package net.sf.l2j.gameserver.model.holder;
66
+
67
+public class RewardHolder
68
+{
69
+	private int _id;
70
+	private int _count;
71
+	private int _chance;
72
+	
73
+	/**
74
+	 * @param rewardId
75
+	 * @param rewardCount
76
+	 */
77
+	public RewardHolder(int rewardId, int rewardCount)
78
+	{
79
+		_id = rewardId;
80
+		_count = rewardCount;
81
+		_chance = 100;
82
+	}
83
+	
84
+	/**
85
+	 * @param rewardId
86
+	 * @param rewardCount
87
+	 * @param rewardChance
88
+	 */
89
+	public RewardHolder(int rewardId, int rewardCount, int rewardChance)
90
+	{
91
+		_id = rewardId;
92
+		_count = rewardCount;
93
+		_chance = rewardChance;
94
+	}
95
+	
96
+	public int getRewardId()
97
+	{
98
+		return _id;
99
+	}
100
+	
101
+	public int getRewardCount()
102
+	{
103
+		return _count;
104
+	}
105
+	
106
+	public int getRewardChance()
107
+	{
108
+		return _chance;
109
+	}
110
+	
111
+	public void setId(int id)
112
+	{
113
+		_id = id;
114
+	}
115
+	
116
+	public void setCount(int count)
117
+	{
118
+		_count = count;
119
+	}
120
+	
121
+	public void setChance(int chance)
122
+	{
123
+		_chance = chance;
124
+	}
125
+}
126
=============================================
127
Index: LuckBox.java
128
=============================================
129
+package ItemsHandler;
130
+
131
+import net.sf.l2j.commons.random.Rnd;
132
+
133
+import net.sf.l2j.Config;
134
+import net.sf.l2j.gameserver.handler.IItemHandler;
135
+import net.sf.l2j.gameserver.model.actor.Playable;
136
+import net.sf.l2j.gameserver.model.actor.Player;
137
+import net.sf.l2j.gameserver.model.holder.RewardHolder;
138
+import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
139
+import net.sf.l2j.gameserver.network.SystemMessageId;
140
+import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
141
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
142
+
143
+/**
144
+ * @author BAN L2JDEV
145
+ *
146
+ */
147
+public class LuckBox implements IItemHandler
148
+{
149
+	private static final int[] ITEM_IDS = new int[]
150
+		{
151
+			Config.LUCKBOXITEMUSEID
152
+		};
153
+	
154
+	
155
+	@Override
156
+	public void useItem(Playable playable, ItemInstance item, boolean forceUse)
157
+	{
158
+		if (!(playable instanceof Player))
159
+			return;
160
+		Player activeChar = (Player) playable;
161
+		if (Config.ENABLE_LUCKBOX)
162
+		{
163
+			switch (Rnd.get(8))
164
+			{
165
+				case 0:
166
+				{
167
+					for (RewardHolder reward : Config.LUCKBOXLIST01)
168
+					{
169
+						if (Rnd.get(100) <= reward.getRewardChance())
170
+						{
171
+							
172
+							activeChar.getInventory().addItem("Cube Reward", reward.getRewardId(), reward.getRewardCount(), activeChar, null);
173
+							
174
+							if (reward.getRewardCount() > 1)
175
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(reward.getRewardId()).addItemNumber(reward.getRewardCount()));
176
+							else
177
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1).addItemName(reward.getRewardId()));
178
+							
179
+						}
180
+					}
181
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
182
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
183
+					activeChar.broadcastPacket(MSU);
184
+					break;
185
+				}
186
+				case 1:
187
+				{
188
+					for (RewardHolder reward : Config.LUCKBOXLIST02)
189
+					{
190
+						if (Rnd.get(100) <= reward.getRewardChance())
191
+						{
192
+							
193
+							activeChar.getInventory().addItem("Cube Reward", reward.getRewardId(), reward.getRewardCount(), activeChar, null);
194
+							
195
+							if (reward.getRewardCount() > 1)
196
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(reward.getRewardId()).addItemNumber(reward.getRewardCount()));
197
+							else
198
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1).addItemName(reward.getRewardId()));
199
+							
200
+						}
201
+					}
202
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
203
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
204
+					activeChar.broadcastPacket(MSU);
205
+					break;
206
+				}
207
+				case 2:
208
+				{
209
+					for (RewardHolder reward : Config.LUCKBOXLIST03)
210
+					{
211
+						if (Rnd.get(100) <= reward.getRewardChance())
212
+						{
213
+							
214
+							activeChar.getInventory().addItem("Cube Reward", reward.getRewardId(), reward.getRewardCount(), activeChar, null);
215
+							
216
+							if (reward.getRewardCount() > 1)
217
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(reward.getRewardId()).addItemNumber(reward.getRewardCount()));
218
+							else
219
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1).addItemName(reward.getRewardId()));
220
+							
221
+						}
222
+					}
223
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
224
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
225
+					activeChar.broadcastPacket(MSU);
226
+					break;
227
+				}
228
+				case 3:
229
+				{
230
+					for (RewardHolder reward : Config.LUCKBOXLIST04)
231
+					{
232
+						if (Rnd.get(100) <= reward.getRewardChance())
233
+						{
234
+							
235
+							activeChar.getInventory().addItem("Cube Reward", reward.getRewardId(), reward.getRewardCount(), activeChar, null);
236
+							
237
+							if (reward.getRewardCount() > 1)
238
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(reward.getRewardId()).addItemNumber(reward.getRewardCount()));
239
+							else
240
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1).addItemName(reward.getRewardId()));
241
+							
242
+						}
243
+					}
244
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
245
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
246
+					activeChar.broadcastPacket(MSU);
247
+					break;
248
+				}
249
+				case 4:
250
+				{
251
+					for (RewardHolder reward : Config.LUCKBOXLIST05)
252
+					{
253
+						if (Rnd.get(100) <= reward.getRewardChance())
254
+						{
255
+							
256
+							activeChar.getInventory().addItem("Cube Reward", reward.getRewardId(), reward.getRewardCount(), activeChar, null);
257
+							
258
+							if (reward.getRewardCount() > 1)
259
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(reward.getRewardId()).addItemNumber(reward.getRewardCount()));
260
+							else
261
+								activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1).addItemName(reward.getRewardId()));
262
+							
263
+						}
264
+					}
265
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
266
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
267
+					activeChar.broadcastPacket(MSU);
268
+					break;
269
+				}
270
+				case 5:
271
+				{
272
+					activeChar.sendMessage("Ohh noo! Your lucky box is empty.");   
273
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
274
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
275
+					activeChar.broadcastPacket(MSU);
276
+					break;
277
+				}
278
+				case 6:
279
+				{
280
+					activeChar.sendMessage("Ohh noo! Your lucky box is empty.");   
281
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
282
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
283
+					activeChar.broadcastPacket(MSU);
284
+					break;
285
+				}
286
+				case 7:
287
+				{
288
+					activeChar.sendMessage("Ohh noo! Your lucky box is empty.");   
289
+					playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
290
+					MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
291
+					activeChar.broadcastPacket(MSU);
292
+					break;
293
+				}
294
+			}
295
+		}
296
+	}
297
+	public int[] getItemIds()
298
+	{
299
+		return ITEM_IDS;
300
+	}
301
+}
302
=============================================
303
Index: ItemHandler.java
304
=============================================
305
		registerHandler(new BeastSoulShots());
306
		registerHandler(new BeastSpices());
307
		registerHandler(new BeastSpiritShots());
308
		registerHandler(new BlessedSpiritShots());
309
+		if (Config.ENABLE_LUCKBOX)
310
+		registerHandler(new LuckBox());
311
312
=============================================
313
Index: config/Dev/ItemHandler.properties
314
=============================================
315
+#=============================================================
316
+#           ItemHandler Settings L2JDEV
317
+#=============================================================
318
+# luck box reward enable
319
+EnableLuckBox = true
320
+LuckBoxItemUseId = 9310
321
+# Format: itemId,count,chance(%);itemId,count,(chance(%)(optional));....
322
+LuckboxRewardList01 = 57,4000000,100;9313,5,5;6393,2000,100;9310,10,100;8762,15,50;8752,15,60;6622,10,60;
323
+LuckboxRewardList02 = 0,0,0;
324
+LuckboxRewardList03 = 0,0,0;
325
+LuckboxRewardList04 = 0,0,0;
326
+LuckboxRewardList05 = 0,0,0;
327
=============================================
328
Index: data/items/Items Hander.xml
329
=============================================
330
+<?xml version="1.0" encoding="UTF-8"?>
331
+<list>
332
+		<item id="9310" type="EtcItem" name="Luck Box Reward Items">
333
+		<set name="is_tradable" val="false" />
334
+		<set name="is_dropable" val="false" />
335
+		<set name="is_sellable" val="false" />
336
+		<set name="is_depositable" val="false" />
337
+		<set name="material" val="PAPER" />
338
+		<set name="weight" val="120" />
339
+		<set name="price" val="500000" />
340
+		<set name="is_oly_restricted" val="true" />
341
+		<set name="is_stackable" val="true" />
342
+		<set name="handler" val="LuckBox" />
343
+	</item>
344
+<list>
345
346
=============================================
347
Index: system/itemname-e.dat
348
=============================================
349
9310	Magic Box Reward Item 	Exclusive 	Reward All Items From Mitrill	-1					0	0	0	
350
=============================================
351
Index: system/etcitemgrp.dat
352
=============================================
353
2	9310	0	5	4	1	0	DropItems.coin_m00			DropItemsTex.coin_t00	DropItemsTex.coin_t01		Icons.quest_coin					0	0	3	0	0	1		1		ItemSound2.itemdrop_etc_money_2		3	0	0
354
=============================================
355
Index: system/Icons.u Copy
356
=============================================
357
https://mega.nz/file/JQBCBLxY#th4KsroT4x8kaIy8pyoqVPlrA_kcPG3-d1_sXBKWjJQ
358