View difference between Paste ID: dUNH4HTE and QU0PTRyc
SHOW: | | - or go back to the newest paste.
1
===========================================
2
Index: config.java
3
==============================================
4
5
+	private static final String SIEGE = "./config/main/Siege.ini";
6
7
+	public static List<int[]> LEADER_REWARD_WINNER_SIEGE_CLAN = new ArrayList<>();
8
+	public static List<int[]> REWARD_WINNER_SIEGE_CLAN = new ArrayList<>();
9
10
11
+	public static void loadSiegeConfig()
12
+	{
13
+		final PropertiesParser Siege = new PropertiesParser(SIEGE);
14
+		
15
+		SIEGE_ENABLE_RENEWAL = Siege.getBoolean("EnableRenewal", true);
16
+		
17
+		if (SIEGE_ENABLE_RENEWAL)
18
+		{
19
+			String[] propertySplit = Siege.getString("LeaderRewardsID", "57,0").split(";");
20
+			for (String reward : propertySplit)
21
+			{
22
+				final String[] rewardSplit = reward.split(",");
23
+				if (rewardSplit.length != 2)
24
+				{
25
+					LOGGER.warning("LeaderRewardsID[Config.load()]: invalid config property -> LeaderRewardsID \"" + reward + "\"");
26
+				}
27
+				else
28
+				{
29
+					try
30
+					{
31
+						LEADER_REWARD_WINNER_SIEGE_CLAN.add(new int[]
32
+						{
33
+							Integer.parseInt(rewardSplit[0]),
34
+							Integer.parseInt(rewardSplit[1])
35
+						});
36
+					}
37
+					catch (NumberFormatException nfe)
38
+					{
39
+						if (!reward.isEmpty())
40
+						{
41
+							LOGGER.warning("LeaderRewardsID[Config.load()]: invalid config property -> LeaderRewardsID \"" + reward + "\"");
42
+						}
43
+					}
44
+				}
45
+			}
46
+		}
47
+		
48
+		if (SIEGE_ENABLE_RENEWAL)
49
+		{
50
+			String[] propertySplit1 = Siege.getString("MembersRewardsID", "57,0").split(";");
51
+			for (String reward : propertySplit1)
52
+			{
53
+				final String[] rewardSplit = reward.split(",");
54
+				if (rewardSplit.length != 2)
55
+				{
56
+					LOGGER.warning("MembersRewardsID[Config.load()]: invalid config property -> MembersRewardsID \"" + reward + "\"");
57
+				}
58
+				else
59
+				{
60
+					try
61
+					{
62
+						REWARD_WINNER_SIEGE_CLAN.add(new int[]
63
+						{
64
+							Integer.parseInt(rewardSplit[0]),
65
+							Integer.parseInt(rewardSplit[1])
66
+						});
67
+					}
68
+					catch (NumberFormatException nfe)
69
+					{
70
+						if (!reward.isEmpty())
71
+						{
72
+							LOGGER.warning("MembersRewardsID[Config.load()]: invalid config property -> MembersRewardsID \"" + reward + "\"");
73
+						}
74
+					}
75
+				}
76
+			}
77
+		}
78
+	}
79
		
80
81
+	loadSiegeConfig();		
82
83
======================================================
84
Index: gameserver.model.entity.siege.Siege.java
85
======================================================
86
87
88
	public void endSiege()
89
	{
90
		if (_isInProgress)
91
		{
92
			announceToPlayer("The siege of " + getCastle().getName() + " has finished!", false);
93
			final PlaySound sound = new PlaySound("systemmsg_e.18");
94
			
95
			for (PlayerInstance player : World.getInstance().getAllPlayers())
96
			{
97
+				// Renewal Leader / Memebers
98
+				checkRenewal(player);
99
				player.sendPacket(sound);
100
			}
101
			
102
	/**
103
	 * Gets the siege guard manager.
104
	 * @return the siege guard manager
105
	 */
106
	public SiegeGuardManager getSiegeGuardManager()
107
	{
108
		if (_siegeGuardManager == null)
109
		{
110
			_siegeGuardManager = new SiegeGuardManager(getCastle());
111
		}
112
		return _siegeGuardManager;
113
	}
114
115
	
116
+	public static void checkRenewal(PlayerInstance activeChar)
117
+	{
118
+		PlayerInstance player = activeChar.getActingPlayer();
119
+		boolean _canReward = false;
120
+		HashMap<String, Integer> playerIps = new HashMap<>();
121
+		
122
+		if (player.isInParty())
123
+		{
124
+			List<PlayerInstance> party = player.getParty().getPartyMembers();
125
+			
126
+			for (PlayerInstance member : party)
127
+			{
128
+				String pIp = member.getClient().getConnection().getInetAddress().getHostAddress();
129
+				
130
+				if (!playerIps.containsKey(pIp))
131
+				{
132
+					playerIps.put(pIp, 1);
133
+					_canReward = true;
134
+				}
135
+				else
136
+				{
137
+					int count = playerIps.get(pIp);
138
+					
139
+					if (count < 1)
140
+					{
141
+						playerIps.remove(pIp);
142
+						playerIps.put(pIp, count + 1);
143
+						_canReward = true;
144
+					}
145
+					else
146
+					{
147
+						member.sendMessage("Already 1 member of your ip have been rewarded, so this character won't be rewarded.");
148
+						_canReward = false;
149
+					}
150
+				}
151
+				if (_canReward)
152
+				{
153
+					if (member.isInsideRadius(player, 1600, false, false))
154
+					{
155
+						if (Rnd.get(100) < 100)
156
+						{
157
+							if (Config.SIEGE_ENABLE_RENEWAL)
158
+							{
159
+								
160
+								if (activeChar.isClanLeader())
161
+								{
162
+									for (int[] reward : Config.LEADER_REWARD_WINNER_SIEGE_CLAN)
163
+									{
164
+										if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
165
+										{
166
+											
167
+											activeChar.addItem("Leader Renewal", reward[0], reward[1], null, true);
168
+										}
169
+										
170
+									}
171
+								}
172
+								else
173
+								{
174
+									for (int[] reward1 : Config.REWARD_WINNER_SIEGE_CLAN)
175
+									{
176
+										if (ItemTable.getInstance().createDummyItem(reward1[0]).isStackable())
177
+										{
178
+											
179
+											activeChar.addItem("Member Renewal", reward1[0], reward1[1], null, true);
180
+										}
181
+										
182
+									}
183
+									
184
+								}
185
+								player.broadcastPacket(new PlaySound("ItemSound.quest_finish"));
186
+							}
187
+						}
188
+						
189
+					}
190
+					else
191
+					{
192
+						member.sendMessage("You are too far to be rewarded.");
193
+					}
194
+				}
195
+			}
196
+			playerIps.clear();
197
+		}
198
+		else
199
+		{
200
+			if (Rnd.get(100) < 100)
201
+			{
202
+				if (Config.SIEGE_ENABLE_RENEWAL)
203
+				{
204
+					
205
+					if (activeChar.isClanLeader())
206
+					{
207
+						for (int[] reward : Config.LEADER_REWARD_WINNER_SIEGE_CLAN)
208
+						{
209
+							if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
210
+							{
211
+								
212
+								activeChar.addItem("Leader Renewal", reward[0], reward[1], null, true);
213
+							}
214
+							
215
+						}
216
+					}
217
+					else
218
+					{
219
+						for (int[] reward1 : Config.REWARD_WINNER_SIEGE_CLAN)
220
+						{
221
+							if (ItemTable.getInstance().createDummyItem(reward1[0]).isStackable())
222
+							{
223
+								
224
+								activeChar.addItem("Member Renewal", reward1[0], reward1[1], null, true);
225
+							}
226
+							
227
+						}
228
+						
229
+					}
230
+					player.broadcastPacket(new PlaySound("ItemSound.quest_finish"));
231
+				}
232
+			}
233
+		}
234
+		
235
+	}
236
237
==============================================
238
Index: Config/main/Siege.ini
239
240
241
# The minimum level for registration
242
SiegeClanMinLevel = 4
243
244
+EnableRenewal = True
245
246
+#The End Siege Renewal
247
+LeaderRewardsID = 57,1
248
+MembersRewardsID = 57,2