View difference between Paste ID: jsv2yaLv and 5pgQFVA8
SHOW: | | - or go back to the newest paste.
1
### Eclipse Workspace Patch 1.0
2
#P L2UFS
3
Index: dist/config/players.properties
4
===================================================================
5
--- dist/config/players.properties	(revision 171)
6
+++ dist/config/players.properties	(working copy)
7
@@ -29,6 +29,11 @@
8
 # Consume shots (Soulshots, BlessedSpiritShots, Spiritshots, BeastSoulShot)
9
 ConsumeSpiritSoulShots = True
10
 
11
+# Enable / disable pvp reward
12
+# Note: pvp_reward.xml are located in "data/xml" folder
13
+# Default: false
14
+EnablePvpReward = true
15
+
16
 #=============================================================
17
 #                           Misc
18
 #=============================================================
19
Index: dist/data/html/admin/server_menu.htm
20
===================================================================
21
--- dist/data/html/admin/server_menu.htm	(revision 170)
22
+++ dist/data/html/admin/server_menu.htm	(working copy)
23
@@ -18,7 +18,7 @@
24
 	Reload
25
 	<table width=240>
26
 		<tr>
27
-			<td><combobox width=120 height=21 var="cb" list=acar;announcement;config;crest;cw;door;htm;item;multisell;npc;npcwalker;skill;teleport;zone;></td>
28
+			<td><combobox width=120 height=21 var="cb" list=acar;announcement;config;crest;cw;door;htm;item;multisell;npc;npcwalker;pvp;skill;teleport;zone;></td>
29
 			<td><button value="Reload" action="bypass -h admin_reload $cb" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal"></td>
30
 		</tr>
31
 	</table><br>
32
Index: java/net/sf/l2j/gameserver/GameServer.java
33
===================================================================
34
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 170)
35
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
36
@@ -57,6 +57,7 @@
37
 import net.sf.l2j.gameserver.datatables.MultisellData;
38
 import net.sf.l2j.gameserver.datatables.NpcTable;
39
 import net.sf.l2j.gameserver.datatables.NpcWalkerRoutesTable;
40
+import net.sf.l2j.gameserver.datatables.PvpRewardTable;
41
 import net.sf.l2j.gameserver.datatables.RecipeTable;
42
 import net.sf.l2j.gameserver.datatables.ServerMemo;
43
 import net.sf.l2j.gameserver.datatables.SkillTable;
44
@@ -206,6 +207,9 @@
45
 		PartyMatchRoomList.getInstance();
46
 		RaidBossPointsManager.getInstance();
47
 		
48
+		if (Config.ENABLE_PVP_REWARD)
49
+			PvpRewardTable.getInstance();
50
+		
51
 		StringUtil.printSection("Community server");
52
 		if (Config.ENABLE_COMMUNITY_BOARD) // Forums has to be loaded before clan data
53
 			ForumsBBSManager.getInstance().initRoot();
54
Index: java/net/sf/l2j/gameserver/datatables/PvpRewardTable.java
55
===================================================================
56
--- java/net/sf/l2j/gameserver/datatables/PvpRewardTable.java	(nonexistent)
57
+++ java/net/sf/l2j/gameserver/datatables/PvpRewardTable.java	(working copy)
58
@@ -0,0 +1,136 @@
59
+/*
60
+ * This program is free software: you can redistribute it and/or modify it under
61
+ * the terms of the GNU General Public License as published by the Free Software
62
+ * Foundation, either version 3 of the License, or (at your option) any later
63
+ * version.
64
+ *
65
+ * This program is distributed in the hope that it will be useful, but WITHOUT
66
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
67
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
68
+ * details.
69
+ *
70
+ * You should have received a copy of the GNU General Public License along with
71
+ * this program. If not, see <http://www.gnu.org/licenses/>.
72
+ */
73
+package net.sf.l2j.gameserver.datatables;
74
+
75
+import java.io.File;
76
+import java.util.ArrayList;
77
+import java.util.List;
78
+import java.util.logging.Logger;
79
+
80
+import net.sf.l2j.gameserver.templates.StatsSet;
81
+import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
82
+
83
+import org.w3c.dom.Document;
84
+import org.w3c.dom.NamedNodeMap;
85
+import org.w3c.dom.Node;
86
+
87
+/**
88
+ * @author rapfersan92
89
+ */
90
+public class PvpRewardTable
91
+{
92
+	protected static final Logger _log = Logger.getLogger(PvpRewardTable.class.getName());
93
+	
94
+	private static List<PvpReward> _pvpRewards;
95
+	
96
+	public static PvpRewardTable getInstance()
97
+	{
98
+		return SingletonHolder._instance;
99
+	}
100
+	
101
+	private static class SingletonHolder
102
+	{
103
+		protected static final PvpRewardTable _instance = new PvpRewardTable();
104
+	}
105
+	
106
+	protected PvpRewardTable()
107
+	{
108
+		_pvpRewards = new ArrayList<>();
109
+		loadPvpReward();
110
+	}
111
+	
112
+	public void reload()
113
+	{
114
+		_pvpRewards.clear();
115
+		loadPvpReward();
116
+	}
117
+	
118
+	private void loadPvpReward()
119
+	{
120
+		try
121
+		{
122
+			File f = new File("./data/xml/pvp_reward.xml");
123
+			Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
124
+			
125
+			Node n = doc.getFirstChild();
126
+			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
127
+			{
128
+				if (d.getNodeName().equalsIgnoreCase("template"))
129
+				{
130
+					NamedNodeMap attrs = d.getAttributes();
131
+					int pvpAmount = Integer.valueOf(attrs.getNamedItem("pvpAmount").getNodeValue());
132
+					int itemId = Integer.valueOf(attrs.getNamedItem("itemId").getNodeValue());
133
+					int itemCount = Integer.valueOf(attrs.getNamedItem("itemCount").getNodeValue());
134
+					double chance = Double.valueOf(attrs.getNamedItem("chance").getNodeValue());
135
+					
136
+					StatsSet set = new StatsSet();
137
+					set.set("pvpAmount", pvpAmount);
138
+					set.set("itemId", itemId);
139
+					set.set("itemCount", itemCount);
140
+					set.set("chance", chance);
141
+					
142
+					_pvpRewards.add(new PvpReward(set));
143
+				}
144
+			}
145
+		}
146
+		catch (Exception e)
147
+		{
148
+			_log.warning("Exception: PvpRewardTable loadPvpReward: " + e);
149
+		}
150
+		
151
+		_log.info("PvpRewardTable: Loaded " + _pvpRewards.size() + " reward's template(s).");
152
+	}
153
+	
154
+	public List<PvpReward> getPvpRewardsTable()
155
+	{
156
+		return _pvpRewards;
157
+	}
158
+	
159
+	public class PvpReward
160
+	{
161
+		private int _pvpAmount;
162
+		private int _itemId;
163
+		private int _itemCount;
164
+		private double _chance;
165
+		
166
+		public PvpReward(StatsSet set)
167
+		{
168
+			_pvpAmount = set.getInteger("pvpAmount");
169
+			_itemId = set.getInteger("itemId");
170
+			_itemCount = set.getInteger("itemCount");
171
+			_chance = set.getDouble("chance");
172
+		}
173
+		
174
+		public int getPvpAmount()
175
+		{
176
+			return _pvpAmount;
177
+		}
178
+		
179
+		public int getItemId()
180
+		{
181
+			return _itemId;
182
+		}
183
+		
184
+		public int getItemCount()
185
+		{
186
+			return _itemCount;
187
+		}
188
+		
189
+		public double getChance()
190
+		{
191
+			return _chance;
192
+		}
193
+	}
194
+}
195
\ No newline at end of file
196
Index: java/net/sf/l2j/Config.java
197
===================================================================
198
--- java/net/sf/l2j/Config.java	(revision 170)
199
+++ java/net/sf/l2j/Config.java	(working copy)
200
@@ -413,7 +413,7 @@
201
 	public static boolean AUTO_ACTIVATE_SHOTS;
202
 	public static int AUTO_ACTIVATE_SHOTS_MIN;
203
 	public static boolean CONSUME_SPIRIT_SOUL_SHOTS;
204
-	
205
+	public static boolean ENABLE_PVP_REWARD;
206
 	public static boolean EFFECT_CANCELING;
207
 	public static double HP_REGEN_MULTIPLIER;
208
 	public static double MP_REGEN_MULTIPLIER;
209
@@ -1168,6 +1168,8 @@
210
 		AUTO_ACTIVATE_SHOTS = players.getProperty("AutoActivateShotsEnabled", false);
211
 		AUTO_ACTIVATE_SHOTS_MIN = players.getProperty("AutoActivateShotsMin", 200);
212
 		CONSUME_SPIRIT_SOUL_SHOTS = players.getProperty("ConsumeSpiritSoulShots", true);
213
+		ENABLE_PVP_REWARD = players.getProperty("EnablePvpReward", false);
214
+
215
 		
216
 		EFFECT_CANCELING = players.getProperty("CancelLesserEffect", true);
217
 		HP_REGEN_MULTIPLIER = players.getProperty("HpRegenMultiplier", 1.);
218
Index: dist/data/xml/pvp_reward.xml
219
===================================================================
220
--- dist/data/xml/pvp_reward.xml	(nonexistent)
221
+++ dist/data/xml/pvp_reward.xml	(working copy)
222
@@ -0,0 +1,4 @@
223
+<?xml version='1.0' encoding='utf-8'?>
224
+<list>
225
+       <template pvpAmount="5" itemId="5592" itemCount="10" chance="1.0"/>
226
+</list>
227
\ No newline at end of file
228
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java
229
===================================================================
230
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java	(revision 170)
231
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminAdmin.java	(working copy)
232
@@ -28,6 +28,7 @@
233
 import net.sf.l2j.gameserver.datatables.MultisellData;
234
 import net.sf.l2j.gameserver.datatables.NpcTable;
235
 import net.sf.l2j.gameserver.datatables.NpcWalkerRoutesTable;
236
+import net.sf.l2j.gameserver.datatables.PvpRewardTable;
237
 import net.sf.l2j.gameserver.datatables.SkillTable;
238
 import net.sf.l2j.gameserver.datatables.TeleportLocationTable;
239
 import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
240
@@ -240,6 +241,11 @@
241
 						NpcWalkerRoutesTable.getInstance().reload();
242
 						activeChar.sendMessage("NPCwalkers' routes have been reloaded.");
243
 					}
244
+					else if (type.startsWith("pvp"))
245
+					{
246
+						PvpRewardTable.getInstance().reload();
247
+						activeChar.sendMessage("Pvp's reward have been reloaded.");
248
+					}
249
 					else if (type.startsWith("skill"))
250
 					{
251
 						SkillTable.getInstance().reload();
252
@@ -259,7 +265,7 @@
253
 					{
254
 						activeChar.sendMessage("Usage : //reload <acar|announcement|config|crest|door>");
255
 						activeChar.sendMessage("Usage : //reload <htm|item|multisell|npc|npcwalker>");
256
-						activeChar.sendMessage("Usage : //reload <skill|teleport|zone>");
257
+						activeChar.sendMessage("Usage : //reload <pvp|skill|teleport|zone>");
258
 					}
259
 				}
260
 				while (st.hasMoreTokens());
261
@@ -268,7 +274,7 @@
262
 			{
263
 				activeChar.sendMessage("Usage : //reload <acar|announcement|config|crest|door>");
264
 				activeChar.sendMessage("Usage : //reload <htm|item|multisell|npc|npcwalker>");
265
-				activeChar.sendMessage("Usage : //reload <skill|teleport|zone>");
266
+				activeChar.sendMessage("Usage : //reload <pvp|skill|teleport|zone>");
267
 			}
268
 		}
269
 		return true;
270
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
271
===================================================================
272
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 170)
273
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
274
@@ -58,6 +58,8 @@
275
 import net.sf.l2j.gameserver.datatables.ItemTable;
276
 import net.sf.l2j.gameserver.datatables.MapRegionTable;
277
 import net.sf.l2j.gameserver.datatables.NpcTable;
278
+import net.sf.l2j.gameserver.datatables.PvpRewardTable;
279
+import net.sf.l2j.gameserver.datatables.PvpRewardTable.PvpReward;
280
 import net.sf.l2j.gameserver.datatables.RecipeTable;
281
 import net.sf.l2j.gameserver.datatables.SkillTable;
282
 import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
283
@@ -363,7 +365,7 @@
284
 	
285
 	private L2GameClient _client;
286
 	private final Map<Integer, String> _chars = new HashMap<>();
287
-
288
+	
289
 	private String _accountName;
290
 	private long _deleteTimer;
291
 	
292
@@ -410,7 +412,7 @@
293
 	private boolean _antifeedSex;
294
 	public boolean eventSitForced = false;
295
 	public boolean atEvent = false;
296
-
297
+	
298
 	private boolean _isInDuel;
299
 	private DuelState _duelState = DuelState.NO_DUEL;
300
 	private int _duelId;
301
@@ -662,7 +664,7 @@
302
 		
303
 		initCharStatusUpdateValues();
304
 	}
305
-
306
+	
307
 	/**
308
 	 * Create a new L2PcInstance and add it in the characters table of the database.
309
 	 * <ul>
310
@@ -765,7 +767,7 @@
311
 	{
312
 		return (PcStatus) super.getStatus();
313
 	}
314
-		
315
+	
316
 	public final PcAppearance getAppearance()
317
 	{
318
 		return _appearance;
319
@@ -1124,17 +1126,17 @@
320
 	{
321
 		_shortCuts.deleteShortCut(slot, page, fromDb);
322
 	}
323
-
324
+	
325
 	public void restoreShortCuts()
326
 	{
327
 		_shortCuts.restore();
328
 	}
329
-
330
+	
331
 	public void removeAllShortcuts()
332
 	{
333
 		_shortCuts.tempRemoveAll();
334
 	}
335
-
336
+	
337
 	/**
338
 	 * Add a L2Macro to the L2PcInstance _macroses.
339
 	 * @param macro The Macro object to add.
340
@@ -2153,7 +2155,7 @@
341
 				stopEffects(L2EffectType.RELAXING);
342
 			
343
 			broadcastPacket(new ChangeWaitType(this, ChangeWaitType.WT_STANDING));
344
-
345
+			
346
 			// Schedule a stand up task to wait for the animation to finish
347
 			ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
348
 			{
349
@@ -3698,7 +3700,7 @@
350
 					return;
351
 				}
352
 			}
353
-
354
+			
355
 			boolean isParty = (((newTarget instanceof L2PcInstance) && isInParty() && getParty().getPartyMembers().contains(newTarget)));
356
 			
357
 			// Check if the new target is visible
358
@@ -3932,19 +3934,19 @@
359
 		{
360
 			L2PcInstance pk = killer.getActingPlayer();
361
 			
362
-			if(NexusEvents.isInEvent(this))
363
+			if (NexusEvents.isInEvent(this))
364
 			{
365
 				NexusEvents.onDie(this, killer);
366
-				if(pk != null && NexusEvents.isInEvent(pk))
367
+				if (pk != null && NexusEvents.isInEvent(pk))
368
 					NexusEvents.onKill(pk, this);
369
 			}
370
-
371
+			
372
 			// Clear resurrect xp calculation
373
 			setExpBeforeDeath(0);
374
 			
375
 			// Remove uber kills
376
 			_uberKills = 0;
377
-
378
+			
379
 			if (isCursedWeaponEquipped())
380
 				CursedWeaponsManager.getInstance().drop(_cursedWeaponEquippedId, killer);
381
 			else
382
@@ -4104,7 +4106,7 @@
383
 	{
384
 		_uberKills++;
385
 		String text = "";
386
-
387
+		
388
 		if (target == null)
389
 			return;
390
 		
391
@@ -4112,13 +4114,13 @@
392
 		if (targetPlayer == null || targetPlayer == this)
393
 			return;
394
 		
395
-		if(NexusEvents.isInEvent(this) && NexusEvents.canAttack(this, target) && NexusEvents.gainPvpPointsOnEvents())
396
+		if (NexusEvents.isInEvent(this) && NexusEvents.canAttack(this, target) && NexusEvents.gainPvpPointsOnEvents())
397
 		{
398
 			setPvpKills(getPvpKills() + 1);
399
 			sendPacket(new UserInfo(this));
400
 			return;
401
 		}
402
-
403
+		
404
 		// Don't rank up the CW if it was a summon.
405
 		if (isCursedWeaponEquipped() && target instanceof L2PcInstance)
406
 		{
407
@@ -4156,6 +4158,11 @@
408
 				// Add PvP point to attacker.
409
 				setPvpKills(getPvpKills() + 1);
410
 				
411
+				if (Config.ENABLE_PVP_REWARD)
412
+				{
413
+					pvpReward();
414
+				}
415
+				
416
 				// Send UserInfo packet to attacker with its Karma and PK Counter
417
 				sendPacket(new UserInfo(this));
418
 			}
419
@@ -4173,7 +4180,7 @@
420
 			// Send UserInfo packet to attacker with its Karma and PK Counter
421
 			sendPacket(new UserInfo(this));
422
 		}
423
-
424
+		
425
 		if (_uberKills >= 3)
426
 		{
427
 			String names[] =
428
@@ -4772,12 +4779,12 @@
429
 		if (isCursedWeaponEquipped())
430
 			return false;
431
 		
432
-		if(NexusEvents.isInEvent(this))
433
+		if (NexusEvents.isInEvent(this))
434
 		{
435
-			if(!NexusEvents.canBeDisarmed(this))
436
+			if (!NexusEvents.canBeDisarmed(this))
437
 				return false;
438
 		}
439
-
440
+		
441
 		// Unequip the weapon
442
 		ItemInstance wpn = getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
443
 		if (wpn != null)
444
@@ -4839,7 +4846,7 @@
445
 		
446
 		setRunning();
447
 		stopAllToggles();
448
-
449
+		
450
 		Ride mount = new Ride(getObjectId(), Ride.ACTION_MOUNT, pet.getTemplate().getNpcId());
451
 		setMount(pet.getNpcId(), pet.getLevel(), mount.getMountType());
452
 		
453
@@ -4846,7 +4853,7 @@
454
 		_petTemplate = (PetTemplate) pet.getTemplate();
455
 		_petData = _petTemplate.getPetDataEntry(pet.getLevel());
456
 		_mountObjectId = pet.getControlItemId();
457
-
458
+		
459
 		startFeed(pet.getNpcId());
460
 		broadcastPacket(mount);
461
 		
462
@@ -4864,7 +4871,7 @@
463
 		
464
 		setRunning();
465
 		stopAllToggles();
466
-
467
+		
468
 		Ride mount = new Ride(getObjectId(), Ride.ACTION_MOUNT, npcId);
469
 		if (setMount(npcId, getLevel(), mount.getMountType()))
470
 		{
471
@@ -4871,7 +4878,7 @@
472
 			_petTemplate = (PetTemplate) NpcTable.getInstance().getTemplate(npcId);
473
 			_petData = _petTemplate.getPetDataEntry(getLevel());
474
 			_mountObjectId = controlItemId;
475
-
476
+			
477
 			broadcastPacket(mount);
478
 			
479
 			// Notify self and others about speed change
480
@@ -4978,7 +4985,7 @@
481
 			_petTemplate = null;
482
 			_petData = null;
483
 			_mountObjectId = 0;
484
-
485
+			
486
 			storePetFood(petId);
487
 			
488
 			// Notify self and others about speed change
489
@@ -6658,15 +6665,15 @@
490
 			return false;
491
 		}
492
 		
493
-		if(NexusEvents.isInEvent(this))
494
+		if (NexusEvents.isInEvent(this))
495
 		{
496
-			if(!NexusEvents.canUseSkill(this, skill))
497
+			if (!NexusEvents.canUseSkill(this, skill))
498
 			{
499
 				sendPacket(ActionFailed.STATIC_PACKET);
500
 				return false;
501
 			}
502
 		}
503
-
504
+		
505
 		// Cancels the use of skills when player uses a cursed weapon or is flying.
506
 		if ((isCursedWeaponEquipped() && !skill.isDemonicSkill()) // If CW, allow ONLY demonic skills.
507
 			|| (getMountType() == 1 && !skill.isStriderSkill()) // If mounted, allow ONLY Strider skills.
508
@@ -8232,9 +8239,9 @@
509
 		
510
 		try
511
 		{
512
-			if(NexusEvents.isRegistered(this))
513
+			if (NexusEvents.isRegistered(this))
514
 				return false;
515
-
516
+			
517
 			if (_subClasses.size() == Config.MAX_SUBCLASS || classIndex == 0 || _subClasses.containsKey(classIndex))
518
 				return false;
519
 			
520
@@ -9081,7 +9088,7 @@
521
 				OlympiadManager.getInstance().removeDisconnectedCompetitor(this);
522
 			
523
 			NexusEvents.onLogout(this);
524
-
525
+			
526
 			// set the status for pledge member list to OFFLINE
527
 			if (getClan() != null)
528
 			{
529
@@ -9761,7 +9768,7 @@
530
 				html.setFile("data/html/jail_in.htm");
531
 				sendPacket(html);
532
 				
533
-	            setInstanceId(0);
534
+				setInstanceId(0);
535
 				setIsIn7sDungeon(false);
536
 				teleToLocation(-114356, -249645, -2984, 0); // Jail
537
 				break;
538
@@ -10653,13 +10660,13 @@
539
 	{
540
 		return getBaseTemplate().getCollisionHeightBySex(getAppearance().getSex());
541
 	}
542
-
543
+	
544
 	public PlayerEventInfo getEventInfo()
545
 	{
546
 		return _eventInfo;
547
 	}
548
 	
549
-	private PcTemplate createRandomAntifeedTemplate() //TODO Rework
550
+	private PcTemplate createRandomAntifeedTemplate() // TODO Rework
551
 	{
552
 		// @formatter:off
553
 		/*Race race = null;
554
@@ -10688,7 +10695,7 @@
555
 	
556
 	public void startAntifeedProtection(boolean start, boolean broadcast)
557
 	{
558
-		if(!start)
559
+		if (!start)
560
 		{
561
 			getAppearance().setVisibleName(getName());
562
 			_antifeedTemplate = null;
563
@@ -10786,4 +10793,13 @@
564
 		else
565
 			cancelActiveTrade();
566
 	}
567
+	
568
+	private void pvpReward()
569
+	{
570
+		for (PvpReward pvpReward : PvpRewardTable.getInstance().getPvpRewardsTable())
571
+		{
572
+			if (Rnd.nextDouble() < pvpReward.getChance() && getPvpKills() >= pvpReward.getPvpAmount())
573
+				addItem("Pvp Reward", pvpReward.getItemId(), pvpReward.getItemCount(), this, true);
574
+		}
575
+	}
576
 }
577
\ No newline at end of file