· 5 years ago · Apr 15, 2020, 09:00 PM
1### Eclipse Workspace Patch 1.0
2#P L2J_Server_
3Index: java/com/l2jserver/gameserver/model/actor/instance/L2CTeleporterInstance.java
4===================================================================
5--- java/com/l2jserver/gameserver/model/actor/instance/L2CTeleporterInstance.java (revision 0)
6+++ java/com/l2jserver/gameserver/model/actor/instance/L2CTeleporterInstance.java (working copy)
7@@ -0,0 +1,67 @@
8+/*
9+ * This program is free software: you can redistribute it and/or modify it under
10+ * the terms of the GNU General Public License as published by the Free Software
11+ * Foundation, either version 3 of the License, or (at your option) any later
12+ * version.
13+ *
14+ * This program is distributed in the hope that it will be useful, but WITHOUT
15+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17+ * details.
18+ *
19+ * You should have received a copy of the GNU General Public License along with
20+ * this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+package com.l2jserver.gameserver.model.actor.instance;
23+
24+import com.l2jserver.gameserver.cache.HtmCache;
25+import com.l2jserver.gameserver.model.GatekeeperMain;
26+import com.l2jserver.gameserver.model.actor.L2Npc;
27+import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
28+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
29+import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
30+
31+/**
32+ * @author Howler
33+ *
34+ */
35+public class L2CTeleporterInstance extends L2Npc
36+{
37+
38+ /**
39+ * @param objectId
40+ * @param template
41+ */
42+ public L2CTeleporterInstance(int objectId, L2NpcTemplate template)
43+ {
44+ super(objectId, template);
45+ setInstanceType(InstanceType.L2TeleporterInstance);
46+ }
47+
48+ @Override
49+ public void showChatWindow(L2PcInstance playerInstance, int val)
50+ {
51+ if (playerInstance == null)
52+ return;
53+
54+ String htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), "data/html/mods/Gatekeeper/Main.htm");
55+
56+ if (GatekeeperMain.getInstance().getBooleanConfig("Maintenance"))
57+ htmContent = "<html><body><title>Gatekeeper Unavailable</title><center>The gateekeper is on maintenance mode<br>Please come back later</center></body></html>";
58+
59+ if (htmContent != null)
60+ {
61+ NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
62+
63+ npcHtmlMessage.setHtml(htmContent);
64+ npcHtmlMessage.replace("%gkTitle%", GatekeeperMain.getInstance().getConfig("gkTitle"));
65+ npcHtmlMessage.replace("%cats%", GatekeeperMain.getInstance().getPlayerMainWindow());
66+ playerInstance.sendPacket(npcHtmlMessage);
67+ }
68+
69+ playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
70+
71+ }
72+
73+
74+}
75Index: java/com/l2jserver/gameserver/model/entity/Category.java
76===================================================================
77--- java/com/l2jserver/gameserver/model/entity/Category.java (revision 0)
78+++ java/com/l2jserver/gameserver/model/entity/Category.java (working copy)
79@@ -0,0 +1,133 @@
80+/*
81+ * This program is free software: you can redistribute it and/or modify it under
82+ * the terms of the GNU General Public License as published by the Free Software
83+ * Foundation, either version 3 of the License, or (at your option) any later
84+ * version.
85+ *
86+ * This program is distributed in the hope that it will be useful, but WITHOUT
87+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
88+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
89+ * details.
90+ *
91+ * You should have received a copy of the GNU General Public License along with
92+ * this program. If not, see <http://www.gnu.org/licenses/>.
93+ */
94+package com.l2jserver.gameserver.model.entity;
95+
96+import com.l2jserver.gameserver.datatables.GatekeeperData;
97+
98+import javolution.util.FastMap;
99+
100+/**
101+ * @author Howler
102+ *
103+ */
104+public class Category
105+{
106+ private int catId, subCatId, ord;
107+ private String catName;
108+
109+ private FastMap<Integer, Teleport> ownedTps;
110+ private FastMap<Integer, Category> ownedCats;
111+
112+ public Category(int catId, String catName, int subCatId, int ord)
113+ {
114+ ownedTps = new FastMap<Integer, Teleport>();
115+ ownedCats = new FastMap<Integer, Category>();
116+ this.catId = catId;
117+ this.catName = catName;
118+ this.subCatId = subCatId;
119+ this.ord = ord;
120+ }
121+
122+ public int getCategoryId()
123+ {
124+ return catId;
125+ }
126+
127+ public String getCategoryName()
128+ {
129+ return catName;
130+ }
131+
132+ public int getParentCategoryId()
133+ {
134+ return subCatId;
135+ }
136+
137+ public boolean isSub()
138+ {
139+ if (subCatId == 0)
140+ return false;
141+ return true;
142+ }
143+
144+ public int getOrder()
145+ {
146+ return ord;
147+ }
148+
149+ public void setOrder(int val)
150+ {
151+ ord = val;
152+ }
153+
154+ public void addTeleport(Teleport tp)
155+ {
156+ if (getCategoryTeleports().containsKey(tp.getId()))
157+ return;
158+
159+ getCategoryTeleports().put(tp.getId(), tp);
160+ }
161+
162+ public void removeTeleport(Teleport tp)
163+ {
164+ if (!getCategoryTeleports().containsKey(tp.getId()))
165+ return;
166+
167+ getCategoryTeleports().remove(tp.getCategoryId());
168+ }
169+
170+ public void addChildCategory(Category cat)
171+ {
172+ if (getCategoryChilds().containsKey(cat.getCategoryId()))
173+ return;
174+
175+ getCategoryChilds().put(cat.getCategoryId(), cat);
176+ }
177+
178+ public void removeChildCategory(Category cat)
179+ {
180+ if (!getCategoryChilds().containsKey(cat.getCategoryId()))
181+ return;
182+
183+ getCategoryChilds().remove(cat.getCategoryId());
184+ }
185+
186+ public void onDelete()
187+ {
188+ if (!getCategoryChilds().isEmpty())
189+ {
190+ for (Category cat : getCategoryChilds().values())
191+ GatekeeperData.getInstance().deleteCategory(cat);
192+ }
193+ getCategoryChilds().clear();
194+
195+ if (!getCategoryTeleports().isEmpty())
196+ {
197+ for (Teleport tp : getCategoryTeleports().values())
198+ GatekeeperData.getInstance().deleteTeleport(tp);
199+ }
200+ getCategoryTeleports().clear();
201+ }
202+
203+ public FastMap<Integer, Teleport> getCategoryTeleports()
204+ {
205+ return ownedTps;
206+ }
207+
208+ public FastMap<Integer, Category> getCategoryChilds()
209+ {
210+ return ownedCats;
211+ }
212+}
213Index: java/com/l2jserver/gameserver/model/GatekeeperMain.java
214===================================================================
215--- java/com/l2jserver/gameserver/model/GatekeeperMain.java (revision 0)
216+++ java/com/l2jserver/gameserver/model/GatekeeperMain.java (working copy)
217@@ -0,0 +1,781 @@
218+/*
219+ * This program is free software: you can redistribute it and/or modify it under
220+ * the terms of the GNU General Public License as published by the Free Software
221+ * Foundation, either version 3 of the License, or (at your option) any later
222+ * version.
223+ *
224+ * This program is distributed in the hope that it will be useful, but WITHOUT
225+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
226+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
227+ * details.
228+ *
229+ * You should have received a copy of the GNU General Public License along with
230+ * this program. If not, see <http://www.gnu.org/licenses/>.
231+ */
232+package com.l2jserver.gameserver.model;
233+
234+import java.io.BufferedReader;
235+import java.io.IOException;
236+import java.io.InputStreamReader;
237+import java.net.URL;
238+import java.net.URLConnection;
239+import java.util.concurrent.Future;
240+
241+import javolution.util.FastList;
242+import javolution.util.FastMap;
243+
244+import com.l2jserver.gameserver.ThreadPoolManager;
245+import com.l2jserver.gameserver.cache.HtmCache;
246+import com.l2jserver.gameserver.datatables.GatekeeperData;
247+import com.l2jserver.gameserver.datatables.TeleportLocationTable;
248+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
249+import com.l2jserver.gameserver.model.entity.Category;
250+import com.l2jserver.gameserver.model.entity.Teleport;
251+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
252+
253+/**
254+ * @author Howler
255+ *
256+ */
257+public class GatekeeperMain
258+{
259+ private volatile static GatekeeperMain singleton;
260+
261+ private String VERSION;
262+
263+ private FastMap<Integer, Teleport> tps;
264+ private FastMap<Integer, Category> cats;
265+ private FastMap<String, String> configs;
266+ private FastMap<Integer, String> nTps;
267+ private Future<?> locCheck;
268+ private FastList<String> searchResult;
269+
270+ public GatekeeperMain()
271+ {
272+ tps = new FastMap<Integer, Teleport>();
273+ cats = new FastMap<Integer, Category>();
274+ configs = new FastMap<String, String>();
275+ nTps = new FastMap<Integer, String>();
276+ searchResult = new FastList<String>();
277+ VERSION = "Alpha 0.4v";
278+ }
279+
280+ public boolean bypassHandler(String command, L2PcInstance activeChar)
281+ {
282+ if (command.startsWith("admin") && !activeChar.isGM())
283+ {
284+ sendWindow("<html><body><center><font color=LEVEL>Unauthorized to access this place</font></center></body></html>", activeChar);
285+ return false;
286+ }
287+
288+ if (command.startsWith("adminPanel"))
289+ sendWindow(sendAdminPanelWindow("main"), activeChar);
290+ else if (command.startsWith("adminTools"))
291+ sendWindow(sendAdminPanelWindow("tools"), activeChar);
292+ else if (command.startsWith("adminConfig"))
293+ sendWindow(sendAdminPanelWindow("config"), activeChar);
294+ else if (command.startsWith("adminTimeline"))
295+ sendWindow(sendAdminPanelWindow("timeline"), activeChar);
296+ else if (command.startsWith("adminEditConfig"))
297+ {
298+ String configName = command.substring(16);
299+ sendWindow(sendEditConfigWindow(configName), activeChar);
300+ }
301+ else if (command.startsWith("adminSetConfig"))
302+ {
303+ String[] str = command.split(" ");
304+ GatekeeperData.getInstance().updateConfigValue(str[1], str[2]);
305+ sendWindow(sendAdminPanelWindow("config"), activeChar);
306+ }
307+ else if (command.startsWith("adminCatList"))
308+ sendWindow(sendAdminPanelWindow("catList"), activeChar);
309+ else if (command.startsWith("adminShowCatTp"))
310+ {
311+ int id = Integer.parseInt(command.substring(15));
312+ sendWindow(sendAdminPanelWindow(id), activeChar);
313+ }
314+ else if (command.startsWith("adminTpList"))
315+ sendWindow(sendAdminPanelWindow("tpList"), activeChar);
316+ else if (command.startsWith("adminAddTp"))
317+ sendWindow(sendAdminPanelWindow("addTp"), activeChar);
318+ else if (command.startsWith("adminAddCat"))
319+ sendWindow(sendAdminPanelWindow("addCat"), activeChar);
320+ else if (command.startsWith("adminSearchTp"))
321+ sendWindow(sendAdminPanelWindow("searchWin"), activeChar);
322+ else if (command.startsWith("adminTele"))
323+ {
324+ String _id = command.substring(10);
325+ int id = Integer.parseInt(_id);
326+ getTeleports().get(id).doTeleport(activeChar);
327+ }
328+ else if (command.startsWith("adminDelCat"))
329+ {
330+ String _id = command.substring(12);
331+ int id = Integer.parseInt(_id);
332+ GatekeeperData.getInstance().deleteCategory(getCategories().get(id));
333+ sendWindow(sendAdminPanelWindow("main"), activeChar);
334+ }
335+ else if (command.startsWith("adminDelTele"))
336+ {
337+ String _id = command.substring(13);
338+ int id = Integer.parseInt(_id);
339+ GatekeeperData.getInstance().deleteTeleport(getTeleports().get(id));
340+ sendWindow(sendAdminPanelWindow("main"), activeChar);
341+ }
342+ else if (command.startsWith("adminCategoryAdd"))
343+ {
344+ String[] args = command.split(" ");
345+
346+ String name = args[1];
347+ String catName = args[2];
348+ int subCatId = 0;
349+
350+ if (!catName.equals("None"))
351+ subCatId = GatekeeperData.getInstance().getCatByName(catName).getCategoryId();
352+
353+ GatekeeperData.getInstance().createCategory(name, subCatId);
354+ sendWindow(sendAdminPanelWindow("main"), activeChar);
355+ }
356+ else if (command.startsWith("adminAddTeleport"))
357+ {
358+ String[] args = command.split(" ");
359+
360+ String name = args[1];
361+ int x = activeChar.getX();
362+ int y = activeChar.getY();
363+ int z = activeChar.getZ();
364+ int maxDist = Integer.parseInt(args[3]);
365+ boolean isParty = Boolean.parseBoolean(args[4]);
366+ boolean isClan = Boolean.parseBoolean(args[5]);
367+ boolean isFlagZone = Boolean.parseBoolean(args[6]);
368+ String _itemId = args[7];
369+ int itemId = 0;
370+ if (!_itemId.equalsIgnoreCase("None"))
371+ itemId = Integer.parseInt(_itemId);
372+ int itemCount = Integer.parseInt(args[8]);
373+
374+ Category cat = GatekeeperData.getInstance().getCatByName(args[2]);
375+
376+ GatekeeperData.getInstance().createTeleport(name, x, y, z, maxDist, isParty, isClan, isFlagZone, itemId, itemCount, cat, "None");
377+ sendWindow(sendAdminPanelWindow("main"), activeChar);
378+ }
379+ else if (command.startsWith("playerCatTpList"))
380+ {
381+ int id = Integer.parseInt(command.substring(16));
382+ sendWindow(sendPlayerWindow(id), activeChar);
383+ }
384+ else if (command.startsWith("playerTele"))
385+ {
386+ String _id = command.substring(11);
387+ int id = Integer.parseInt(_id);
388+ getTeleports().get(id).doTeleport(activeChar);
389+ }
390+ else if (command.startsWith("adminNextTimeline"))
391+ {
392+ String _id = command.substring(18);
393+ sendWindow(sendAdminPanelWindow("tl " + _id), activeChar);
394+ }
395+ else if (command.startsWith("adminBackTimeline"))
396+ {
397+ String _id = command.substring(18);
398+ sendWindow(sendAdminPanelWindow("tl " + _id), activeChar);
399+ }
400+ else if (command.startsWith("adminLinkTimeline"))
401+ {
402+ String file = command.substring(18);
403+ sendWindow(sendAdminPanelWindow("linkTl " + file), activeChar);
404+ }
405+ else if (command.startsWith("adminSearch"))
406+ {
407+ String keyword = command.substring(12);
408+ sendWindow(sendAdminPanelSearch(keyword), activeChar);
409+ }
410+ else if (command.startsWith("adminNextSearch"))
411+ {
412+ String[] data = command.split(" ");
413+ sendWindow(sendAdminPanelSearch(data[1], Integer.parseInt(data[2])), activeChar);
414+ }
415+ else if (command.startsWith("adminBackSearch"))
416+ {
417+ String[] data = command.split(" ");
418+ sendWindow(sendAdminPanelSearch(data[1], Integer.parseInt(data[2])), activeChar);
419+ }
420+ else if (command.startsWith("adminAddSearch"))
421+ {
422+ String id = command.substring(15);
423+ sendWindow(sendAdminPanelWindow("addSearch " + id), activeChar);
424+ }
425+ else if (command.startsWith("adminAddNormalTeleport"))
426+ {
427+ String[] args = command.split(" ");
428+ L2TeleportLocation ltl = TeleportLocationTable.getInstance().getTemplate(Integer.parseInt(args[1]));
429+ String name = args[2];
430+ int x = ltl.getLocX();
431+ int y = ltl.getLocY();
432+ int z = ltl.getLocZ();
433+ int maxDist = Integer.parseInt(args[4]);
434+ boolean isParty = Boolean.parseBoolean(args[5]);
435+ boolean isClan = Boolean.parseBoolean(args[6]);
436+ boolean isFlagZone = Boolean.parseBoolean(args[7]);
437+ String _itemId = args[8];
438+ int itemId = 0;
439+ if (!_itemId.equalsIgnoreCase("None"))
440+ itemId = Integer.parseInt(_itemId);
441+ int itemCount = Integer.parseInt(args[9]);
442+
443+ Category cat = GatekeeperData.getInstance().getCatByName(args[3]);
444+
445+ GatekeeperData.getInstance().createTeleport(name, x, y, z, maxDist, isParty, isClan, isFlagZone, itemId, itemCount, cat, "None");
446+ sendWindow(sendAdminPanelWindow("main"), activeChar);
447+ }
448+ else if (command.startsWith("adminTpOrdUp"))
449+ {
450+ String _id = command.split(" ")[1];
451+ int id = Integer.parseInt(_id);
452+ GatekeeperData.getInstance().TeleportOrderUp(id);
453+ sendWindow(sendAdminPanelWindow("main"), activeChar);
454+ }
455+ else if (command.startsWith("adminTpOrdDown"))
456+ {
457+ String _id = command.split(" ")[1];
458+ int id = Integer.parseInt(_id);
459+ GatekeeperData.getInstance().TeleportOrderDown(id);
460+ sendWindow(sendAdminPanelWindow("main"), activeChar);
461+ }
462+ else if (command.startsWith("adminCtOrdUp"))
463+ {
464+ int id = Integer.parseInt(command.substring(13));
465+ GatekeeperData.getInstance().CategoryOrderChangeUp(id);
466+ sendWindow(sendAdminPanelWindow("main"), activeChar);
467+ }
468+ else if (command.startsWith("adminCtOrdDown"))
469+ {
470+ int id = Integer.parseInt(command.substring(15));
471+ GatekeeperData.getInstance().CategoryOrderChangeUp(id);
472+ sendWindow(sendAdminPanelWindow("main"), activeChar);
473+ }
474+
475+ return true;
476+ }
477+
478+ public void sendWindow(String content, L2PcInstance activeChar)
479+ {
480+ if (activeChar == null)
481+ return;
482+ if (content != null)
483+ {
484+ NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(5);
485+ npcHtmlMessage.setHtml(content);
486+ activeChar.sendPacket(npcHtmlMessage);
487+ }
488+ }
489+
490+ public String sendAdminPanelWindow(String win)
491+ {
492+ String htmContent = null;
493+ if (win.equals("main"))
494+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminMain.htm");
495+ else if (win.equals("tools"))
496+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminTools.htm");
497+ else if (win.equals("config"))
498+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminConfig.htm");
499+ else if (win.equals("timeline"))
500+ htmContent = getAdminWindowTimeline(0);
501+ else if (win.equals("catList"))
502+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminCategoryList.htm");
503+ else if (win.equals("tpList"))
504+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminTeleportList.htm");
505+ else if (win.equals("addTp"))
506+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminAddTeleport.htm");
507+ else if (win.equals("addCat"))
508+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminAddCategory.htm");
509+ else if (win.equals("searchWin"))
510+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminTeleportSearch.htm");
511+ else if (win.startsWith("tl"))
512+ {
513+ String _id = win.substring(3);
514+ int id = Integer.parseInt(_id);
515+ htmContent = getAdminWindowTimeline(id);
516+ }
517+ else if (win.startsWith("linkTl"))
518+ {
519+ String file = win.substring(7);
520+ htmContent = getAdminWindowTimeline(file);
521+ }
522+ else if (win.startsWith("addSearch"))
523+ {
524+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminAddNormalTeleport.htm");
525+ htmContent = htmContent.replaceAll("%id%", win.substring(10).replaceAll("\\$", "\\\\\\$"));
526+ }
527+
528+ htmContent = htmContent.replaceAll("%gkTitle%", getConfig("gkTitle").replaceAll("\\$", "\\\\\\$"));
529+ htmContent = htmContent.replaceAll("%adminPanel%", getAdminWindowHeader().replaceAll("\\$", "\\\\\\$"));
530+ htmContent = htmContent.replaceAll("%configs%", getConfigWindow().replaceAll("\\$", "\\\\\\$"));
531+ htmContent = htmContent.replaceAll("%categories%", getCategoryListWindow().replaceAll("\\$", "\\\\\\$"));
532+ htmContent = htmContent.replaceAll("%teleports%", getTeleportListWindow().replaceAll("\\$", "\\\\\\$"));
533+ htmContent = htmContent.replaceAll("%availableCat%", getCategoryListString().replaceAll("\\$", "\\\\\\$"));
534+ htmContent = htmContent.replaceAll("<a></a>", getSearchResult("null").replaceAll("\\$", "\\\\\\$"));
535+ htmContent = htmContent.replaceAll("%ver%", VERSION.replaceAll("\\$", "\\\\\\$"));
536+ htmContent = htmContent.replaceAll("%items%", getItems().replaceAll("\\$", "\\\\\\$"));
537+
538+ return htmContent;
539+ }
540+
541+ public String sendAdminPanelSearch(String keyWord, int numb)
542+ {
543+ String htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminTeleportSearch.htm");
544+
545+ htmContent = htmContent.replaceAll("%gkTitle%", getConfig("gkTitle").replaceAll("\\$", "\\\\\\$"));
546+ htmContent = htmContent.replaceAll("%adminPanel%", getAdminWindowHeader().replaceAll("\\$", "\\\\\\$"));
547+ htmContent = htmContent.replaceAll("<a></a>", getSearchResultPage(keyWord, numb).replaceAll("\\$", "\\\\\\$"));
548+
549+ return htmContent;
550+ }
551+
552+ public String sendAdminPanelSearch(String keyword)
553+ {
554+ String htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminTeleportSearch.htm");
555+
556+ htmContent = htmContent.replaceAll("%gkTitle%", getConfig("gkTitle").replaceAll("\\$", "\\\\\\$"));
557+ htmContent = htmContent.replaceAll("%adminPanel%", getAdminWindowHeader().replaceAll("\\$", "\\\\\\$"));
558+ htmContent = htmContent.replaceAll("<a></a>", getSearchResult(keyword).replaceAll("\\$", "\\\\\\$"));
559+
560+ return htmContent;
561+ }
562+
563+ public String sendPlayerWindow(int id)
564+ {
565+ String htmContent = null;
566+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/PlayerCatTp.htm");
567+
568+ htmContent = htmContent.replaceAll("%gkTitle%", getConfig("gkTitle").replaceAll("\\$", "\\\\\\$"));
569+ htmContent = htmContent.replaceAll("%cats%", getPlayerCatWindow(id).replaceAll("\\$", "\\\\\\$"));
570+ htmContent = htmContent.replaceAll("%tps%", getPlayerTpWindow(id).replaceAll("\\$", "\\\\\\$"));
571+ return htmContent;
572+ }
573+
574+ public String sendAdminPanelWindow(int id)
575+ {
576+ String htmContent = null;
577+
578+ htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminCatTeleList.htm");
579+
580+ htmContent = htmContent.replaceAll("%gkTitle%", getConfig("gkTitle").replaceAll("\\$", "\\\\\\$"));
581+ htmContent = htmContent.replaceAll("%adminPanel%", getAdminWindowHeader().replaceAll("\\$", "\\\\\\$"));
582+
583+ htmContent = htmContent.replaceAll("%categories%", getCategoryListByCat(id).replaceAll("\\$", "\\\\\\$"));
584+ htmContent = htmContent.replaceAll("%teleports%", getTeleportListByCat(id).replaceAll("\\$", "\\\\\\$"));
585+
586+ return htmContent;
587+ }
588+
589+ public String sendEditConfigWindow(String configName)
590+ {
591+ String htmContent = HtmCache.getInstance().getHtm("data/html/mods/Gatekeeper/Admin/AdminEditConfig.htm");
592+
593+ htmContent = htmContent.replaceAll("%adminPanel%", getAdminWindowHeader().replaceAll("\\$", "\\\\\\$"));
594+ htmContent = htmContent.replaceAll("%configName%", configName.replaceAll("\\$", "\\\\\\$"));
595+ htmContent = htmContent.replaceAll("%configValue%", getConfigs().get(configName).replaceAll("\\$", "\\\\\\$"));
596+
597+ return htmContent;
598+ }
599+
600+ public String getCategoryListString()
601+ {
602+ String list = "";
603+
604+ for (int id : getCategories().keySet())
605+ {
606+ Category cat = getCategories().get(id);
607+ list += cat.getCategoryName() + ";";
608+ }
609+
610+ return list;
611+ }
612+
613+ public String getCategoryListWindow()
614+ {
615+ String htmContent = "<table bgcolor=777777 width=290><tr><td width=50 align=center>Order</td><td width=154 align=center>Category Name</td><td width=42 align=center>Tools</td><td width=22></td><td width=22></td></tr>";
616+
617+ for (int id : getCategories().keySet())
618+ {
619+ Category cat = getCategories().get(id);
620+ if (cat.isSub())
621+ continue;
622+ htmContent += "<tr><td width=50 align=center>" + cat.getOrder() + "</td><td width=154 align=center><button action=\"bypass -h gk_adminShowCatTp " + cat.getCategoryId() + "\" value=\"" + cat.getCategoryName().replace(".", " ") + "\" width=140 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=42><button action=\"bypass -h gk_adminDelCat " + cat.getCategoryId() + "\" value=\"Del\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminCtOrdUp " + cat.getCategoryId() + "\" value=\"U\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminCtOrdDown " + cat.getCategoryId() + "\" value=\"D\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
623+ }
624+ htmContent += "</table>";
625+ return htmContent;
626+ }
627+
628+ public String getItems()
629+ {
630+ String result = "";
631+
632+ for (String item : getArrayConfig("gkCurrency"))
633+ {
634+ result += item + ";";
635+ }
636+
637+ return result;
638+ }
639+
640+ public String getTeleportListWindow()
641+ {
642+ String htmContent = "<table bgcolor=777777 width=290><tr><td width=50 align=center>Order</td><td width=154 align=center>Teleport Name</td><td width=42 align=center>Tools</td><td width=22></td><td width=22</td></tr>";
643+
644+ for (int _id : getTeleports().keySet())
645+ {
646+ Teleport tele = getTeleports().get(_id);
647+
648+ htmContent += "<tr><td width=50 align=center>" + tele.getOrder() + "</td><td width=154 align=center><button action=\"bypass -h gk_adminTele " + tele.getId() + "\" value=\"" + tele.getName().replace(".", " ") + "\" width=140 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=42><button action=\"bypass -h gk_adminDelTele " + tele.getId() + "\" value=\"Del\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminTpOrdUp " + tele.getId() + "\" value=\"U\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminTpOrdDown " + tele.getId() + "\" value=\"D\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
649+ }
650+
651+ htmContent += "</table>";
652+ return htmContent;
653+ }
654+
655+ public String getCategoryListByCat(int id)
656+ {
657+ String htmContent = "<table bgcolor=777777 width=290><tr><td width=50 align=center>Order</td><td width=154 align=center>Category Name</td><td width=42 align=center>Tools</td><td width=22></td><td width=22></td></tr>";
658+ Category _cat = getCategories().get(id);
659+ for (int _id : _cat.getCategoryChilds().keySet())
660+ {
661+ Category cat = getCategories().get(_id);
662+ if (!cat.isSub())
663+ continue;
664+ htmContent += "<tr><td width=50 align=center>" + cat.getOrder() + "</td><td width=154 align=center><button action=\"bypass -h gk_adminShowCatTp " + cat.getCategoryId() + "\" value=\"" + cat.getCategoryName().replace(".", " ") + "\" width=140 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=42><button action=\"bypass -h gk_adminDelCat " + cat.getCategoryId() + "\" value=\"Del\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminCtOrdUp " + cat.getCategoryId() + "\" value=\"U\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminCtOrdDown " + cat.getCategoryId() + "\" value=\"D\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
665+ }
666+ htmContent += "</table>";
667+ return htmContent;
668+ }
669+
670+ public String getTeleportListByCat(int id)
671+ {
672+ String htmContent = "<table bgcolor=777777 width=290><tr><td width=50 align=center>Order</td><td width=154 align=center>Teleport Name</td><td width=42 align=center>Tools</td><td width=22></td><td width=22</td></tr>";
673+
674+ Category cat = getCategories().get(id);
675+
676+ for (int _id : cat.getCategoryTeleports().keySet())
677+ {
678+ Teleport tele = getTeleports().get(_id);
679+
680+ htmContent += "<tr><td width=50 align=center>" + tele.getOrder() + "</td><td width=154 align=center><button action=\"bypass -h gk_adminTele " + tele.getId() + "\" value=\"" + tele.getName().replace(".", " ") + "\" width=140 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=42><button action=\"bypass -h gk_adminDelTele " + tele.getId() + "\" value=\"Del\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminTpOrdUp " + tele.getId() + "\" value=\"U\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=22><button action=\"bypass -h gk_adminTpOrdDown " + tele.getId() + "\" value=\"D\" width=20 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
681+ }
682+
683+ htmContent += "</table>";
684+ return htmContent;
685+ }
686+
687+ public String getAdminWindowTimeline(int val)
688+ {
689+ String content = null;
690+ String strUrl = null;
691+ if (val != 0)
692+ strUrl = "http://gamespot.isgreat.org/adminTimeline-" + val +".htm";
693+ else
694+ strUrl = "http://gamespot.isgreat.org/adminTimeline.htm";
695+ try
696+ {
697+ URL url = new URL(strUrl);
698+ URLConnection spoof = url.openConnection();
699+
700+ //Spoof the connection so we look like a web browser
701+ spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
702+ BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
703+ String strLine = "";
704+
705+ //Loop through every line in the source
706+ while ((strLine = in.readLine()) != null)
707+ {
708+ content += strLine;
709+ }
710+ }
711+ catch (IOException e)
712+ {
713+ // TODO Auto-generated catch block
714+ e.printStackTrace();
715+ }
716+
717+ return content;
718+ }
719+
720+ public String getAdminWindowTimeline(String file)
721+ {
722+ String content = null;
723+ String strUrl = "http://gamespot.isgreat.org/timeline/" + file + ".htm";
724+ try
725+ {
726+ URL url = new URL(strUrl);
727+ URLConnection spoof = url.openConnection();
728+
729+ //Spoof the connection so we look like a web browser
730+ spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
731+ BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
732+ String strLine = "";
733+
734+ //Loop through every line in the source
735+ while ((strLine = in.readLine()) != null)
736+ {
737+ content += strLine;
738+ }
739+ }
740+ catch (IOException e)
741+ {
742+ // TODO Auto-generated catch block
743+ e.printStackTrace();
744+ }
745+
746+ return content;
747+ }
748+
749+ public String getSearchResult(String keyWord)
750+ {
751+ if (keyWord == "null")
752+ return "Enter a search word";
753+
754+ searchResult.clear();
755+
756+ for (String name : getNormalTeleports().values())
757+ {
758+ String result = name.toLowerCase();
759+
760+ if (name.toLowerCase().contains("->"))
761+ result = name.toLowerCase().split("->")[1];
762+
763+ if (result.contains(keyWord))
764+ searchResult.add(name.toLowerCase());
765+ }
766+
767+ if (searchResult.isEmpty())
768+ return "Nothing founded that match your keyword";
769+
770+ return getSearchResultPage(keyWord, 0);
771+ }
772+
773+ public String getSearchResultPage(String keyWord, int numb)
774+ {
775+ String result = "<table width=300>";
776+ String[] names = searchResult.toArray(new String[0]);
777+ int total = numb+7;
778+ if (searchResult.size()-1 < total)
779+ total = searchResult.size()-1;
780+ for (int page=numb; page<total; page++)
781+ {
782+ if (names[page] != null && names[page] != "")
783+ {
784+ int _id = 0;
785+ for (int id : getNormalTeleports().keySet())
786+ {
787+ String name = getNormalTeleports().get(id);
788+ if (names[page].equalsIgnoreCase(name))
789+ {
790+ _id = id;
791+ break;
792+ }
793+ }
794+ String _result = "";
795+ if (names[page].contains("->"))
796+ _result = names[page].split("->")[1];
797+ else
798+ _result = names[page];
799+ if (!_result.contains(keyWord))
800+ continue;
801+ result += "<tr><td width=200 align=center>" + _result + "</td><td width=100 align=center><button action=\"bypass -h gk_adminAddSearch " + _id + "\" value=\"Add\" width=70 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
802+ }
803+ }
804+
805+ result += "</table><br><table width=300>";
806+
807+ result += "<tr><td width=150 align=left>";
808+ if (numb > 0)
809+ {
810+ int back = numb - 8;
811+ result += "<button action=\"bypass -h gk_adminBackSearch " + keyWord + " " + back + "\" value=\"Back\" width=140 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
812+ }
813+ int next = total+1;
814+ result += "</td><td width=150 align=right>";
815+ if (next <= searchResult.size()-1 )
816+ result += "<button action=\"bypass -h gk_adminNextSearch " + keyWord + " " + next +"\" value=\"Next\" width=140 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">";
817+
818+ result += "</td></tr></table>";
819+
820+
821+ return result;
822+ }
823+
824+ public String getAdminWindowHeader()
825+ {
826+ String output = "<center><table width=\"280\"><tr>";
827+
828+ output += "<td><button action=\"bypass -h gk_adminPanel\" value=\"Main\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
829+ output += "<td><button action=\"bypass -h gk_adminTools\" value=\"Tools\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>";
830+ output += "<td><button action=\"bypass -h gk_adminConfig\" value=\"Config\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
831+
832+ output += "</table></center>";
833+
834+ return output;
835+ }
836+
837+ public String getConfigWindow()
838+ {
839+ String output = "<table width=280>";
840+
841+ for (String name : getConfigs().keySet())
842+ {
843+ String value = getConfigs().get(name);
844+ output += "<tr><td width=140>" + name + "</td><td width=90>" + value + "</td><td width=50><button action=\"bypass -h gk_adminEditConfig " + name + "\" value=\"Edit\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
845+ }
846+
847+ return output;
848+ }
849+
850+ public FastMap<Integer, Teleport> getTeleports()
851+ {
852+ return tps;
853+ }
854+
855+ public synchronized void addTeleport(Teleport tp)
856+ {
857+ if (getTeleports().containsKey(tp.getId()))
858+ return;
859+
860+ getTeleports().put(tp.getId(), tp);
861+ }
862+
863+ public synchronized void addCategory(Category cat)
864+ {
865+ if (getCategories().containsKey(cat.getCategoryId()))
866+ return;
867+
868+ getCategories().put(cat.getCategoryId(), cat);
869+ }
870+
871+ public FastMap<Integer, Category> getCategories()
872+ {
873+ return cats;
874+ }
875+
876+ public FastMap<String, String> getConfigs()
877+ {
878+ return configs;
879+ }
880+
881+ public FastMap<Integer, String> getNormalTeleports()
882+ {
883+ return nTps;
884+ }
885+
886+ public Future<?> getGKLocCheck()
887+ {
888+ return locCheck;
889+ }
890+
891+ public void setGKLocCheck(Runnable r)
892+ {
893+ locCheck = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(r, getIntConfig("GKCheckInitial")*1000, getIntConfig("GKCheckDelay")*1000);
894+ }
895+
896+ public synchronized void addConfig(String configName, String configValue)
897+ {
898+ if (getConfigs().containsKey(configName))
899+ getConfigs().remove(configName);
900+
901+ getConfigs().put(configName, configValue);
902+ }
903+
904+ public String getConfig(String configName)
905+ {
906+ return getConfigs().get(configName);
907+ }
908+
909+ public int getIntConfig(String configName)
910+ {
911+ return Integer.parseInt(getConfig(configName));
912+ }
913+
914+ public boolean getBooleanConfig(String configName)
915+ {
916+ return Boolean.parseBoolean(getConfig(configName));
917+ }
918+
919+ public String[] getArrayConfig(String configName)
920+ {
921+ String[] strArray = getConfig(configName).split(",");
922+ return strArray;
923+ }
924+
925+ public int[] getIntArrayConfig(String configName)
926+ {
927+ String[] strArray = getArrayConfig(configName);
928+ int[] intArray = new int[strArray.length];
929+ for (int i = 0; i < strArray.length; i++)
930+ {
931+ intArray[i] = Integer.parseInt(strArray[i]);
932+ }
933+ return intArray;
934+ }
935+
936+ public String getPlayerMainWindow()
937+ {
938+ String htmContent = "<table width=280>";
939+
940+ for (int id : getCategories().keySet())
941+ {
942+ Category cat = getCategories().get(id);
943+ if (cat.isSub())
944+ continue;
945+ htmContent += "<tr><td align=center><button action=\"bypass -h gk_playerCatTpList " + cat.getCategoryId() + "\" value=\"" + cat.getCategoryName().replace(".", " ") + "\" width=200 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
946+ }
947+ htmContent += "</table>";
948+ return htmContent;
949+ }
950+
951+ public String getPlayerCatWindow(int id)
952+ {
953+ String htmContent = "<table width=280>";
954+ Category _cat = getCategories().get(id);
955+ for (int _id : _cat.getCategoryChilds().keySet())
956+ {
957+ Category cat = getCategories().get(_id);
958+ if (!cat.isSub())
959+ continue;
960+ htmContent += "<tr><td align=center><button action=\"bypass -h gk_playerCatTpList " + cat.getCategoryId() + "\" value=\"" + cat.getCategoryName().replace(".", " ") + "\" width=200 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
961+ }
962+ htmContent += "</table>";
963+ return htmContent;
964+ }
965+
966+ public String getPlayerTpWindow(int id)
967+ {
968+ String htmContent = "<table width=280>";
969+ Category cat = getCategories().get(id);
970+ for (int _id : cat.getCategoryTeleports().keySet())
971+ {
972+ Teleport tp = getTeleports().get(_id);
973+ if (cat.isSub())
974+ continue;
975+ htmContent += "<tr><td align=center><button action=\"bypass -h gk_playerTele " + tp.getId() + "\" value=\"" + tp.getName().replace(".", " ") + "\" width=200 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>";
976+ }
977+ htmContent += "</table>";
978+ return htmContent;
979+ }
980+
981+ public String getVersion()
982+ {
983+ return VERSION;
984+ }
985+
986+ public static GatekeeperMain getInstance()
987+ {
988+ if (singleton == null)
989+ {
990+ synchronized(GatekeeperMain.class)
991+ {
992+ if (singleton == null)
993+ singleton = new GatekeeperMain();
994+ }
995+ }
996+ return singleton;
997+ }
998+}
999Index: java/com/l2jserver/gameserver/GameServer.java
1000===================================================================
1001--- java/com/l2jserver/gameserver/GameServer.java (revision 5131)
1002+++ java/com/l2jserver/gameserver/GameServer.java (working copy)
1003@@ -50,6 +50,7 @@
1004 import com.l2jserver.gameserver.datatables.ExperienceTable;
1005 import com.l2jserver.gameserver.datatables.FishTable;
1006 import com.l2jserver.gameserver.datatables.GMSkillTable;
1007+import com.l2jserver.gameserver.datatables.GatekeeperData;
1008 import com.l2jserver.gameserver.datatables.HelperBuffTable;
1009 import com.l2jserver.gameserver.datatables.HennaTable;
1010 import com.l2jserver.gameserver.datatables.HennaTreeTable;
1011@@ -111,6 +112,7 @@
1012 import com.l2jserver.gameserver.instancemanager.ZoneManager;
1013 import com.l2jserver.gameserver.model.AutoChatHandler;
1014 import com.l2jserver.gameserver.model.AutoSpawnHandler;
1015+import com.l2jserver.gameserver.model.GatekeeperMain;
1016 import com.l2jserver.gameserver.model.L2Manor;
1017 import com.l2jserver.gameserver.model.L2World;
1018 import com.l2jserver.gameserver.model.PartyMatchRoomList;
1019@@ -347,6 +349,8 @@
1020 {
1021 _log.log(Level.SEVERE, "Failed to store Compiled Scripts Cache.", e);
1022 }
1023+ GatekeeperMain.getInstance();
1024+ GatekeeperData.getInstance();
1025 QuestManager.getInstance().report();
1026 TransformationManager.getInstance().report();
1027
1028Index: java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java
1029===================================================================
1030--- java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java (revision 5131)
1031+++ java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
1032@@ -26,6 +26,7 @@
1033 import com.l2jserver.gameserver.handler.BypassHandler;
1034 import com.l2jserver.gameserver.handler.IAdminCommandHandler;
1035 import com.l2jserver.gameserver.handler.IBypassHandler;
1036+import com.l2jserver.gameserver.model.GatekeeperMain;
1037 import com.l2jserver.gameserver.model.L2CharPosition;
1038 import com.l2jserver.gameserver.model.L2Object;
1039 import com.l2jserver.gameserver.model.L2World;
1040@@ -247,6 +248,11 @@
1041 Hero.getInstance().showHeroDiary(player, heroclass, heroid, heropage);
1042 }
1043 }
1044+ else if (_command.startsWith("gk_"))
1045+ {
1046+ String command = _command.substring(3);
1047+ GatekeeperMain.getInstance().bypassHandler(command, getClient().getActiveChar());
1048+ }
1049 else
1050 {
1051 final IBypassHandler handler = BypassHandler.getInstance().getBypassHandler(_command);
1052Index: java/com/l2jserver/gameserver/model/entity/Teleport.java
1053===================================================================
1054--- java/com/l2jserver/gameserver/model/entity/Teleport.java (revision 0)
1055+++ java/com/l2jserver/gameserver/model/entity/Teleport.java (working copy)
1056@@ -0,0 +1,219 @@
1057+/*
1058+ * This program is free software: you can redistribute it and/or modify it under
1059+ * the terms of the GNU General Public License as published by the Free Software
1060+ * Foundation, either version 3 of the License, or (at your option) any later
1061+ * version.
1062+ *
1063+ * This program is distributed in the hope that it will be useful, but WITHOUT
1064+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1065+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1066+ * details.
1067+ *
1068+ * You should have received a copy of the GNU General Public License along with
1069+ * this program. If not, see <http://www.gnu.org/licenses/>.
1070+ */
1071+package com.l2jserver.gameserver.model.entity;
1072+
1073+import com.l2jserver.gameserver.instancemanager.MapRegionManager;
1074+import com.l2jserver.gameserver.model.GatekeeperMain;
1075+import com.l2jserver.gameserver.model.L2ClanMember;
1076+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
1077+
1078+/**
1079+ * @author Howler
1080+ *
1081+ */
1082+public class Teleport
1083+{
1084+ private int id, locx, locy, locz, maxDist, catId, ord, itemId, itemCount;
1085+ private String name, desc;
1086+ private boolean isParty, isClan, isFlagZone;
1087+
1088+ public Teleport(int id, String name, int locx, int locy, int locz, int maxDist, boolean isParty, boolean isClan, boolean isFlagZone, int itemId, int itemCount, int catId, int ord, String desc)
1089+ {
1090+ this.id = id;
1091+ this.name = name;
1092+ this.locx = locx;
1093+ this.locy = locy;
1094+ this.locz = locz;
1095+ this.maxDist = maxDist;
1096+ this.isParty = isParty;
1097+ this.isClan = isClan;
1098+ this.isFlagZone = isFlagZone;
1099+ this.itemId = itemId;
1100+ this.itemCount = itemCount;
1101+ this.catId = catId;
1102+ this.ord = ord;
1103+ this.desc = desc;
1104+ }
1105+
1106+ public int getId()
1107+ {
1108+ return id;
1109+ }
1110+
1111+ public int getLocX()
1112+ {
1113+ return locx;
1114+ }
1115+
1116+ public int getLocY()
1117+ {
1118+ return locy;
1119+ }
1120+
1121+ public int getLocZ()
1122+ {
1123+ return locz;
1124+ }
1125+
1126+ public int getMaxDist()
1127+ {
1128+ return maxDist;
1129+ }
1130+
1131+ public int getCategoryId()
1132+ {
1133+ return catId;
1134+ }
1135+
1136+ public int getItemId()
1137+ {
1138+ return itemId;
1139+ }
1140+
1141+ public int getItemCount()
1142+ {
1143+ return itemCount;
1144+ }
1145+
1146+ public int getOrder()
1147+ {
1148+ return ord;
1149+ }
1150+
1151+ public String getName()
1152+ {
1153+ return name;
1154+ }
1155+
1156+ public String getDesc()
1157+ {
1158+ return desc;
1159+ }
1160+
1161+ public boolean isParty()
1162+ {
1163+ return isParty;
1164+ }
1165+
1166+ public boolean isClan()
1167+ {
1168+ return isClan;
1169+ }
1170+
1171+ public boolean isFlagZone()
1172+ {
1173+ return isFlagZone;
1174+ }
1175+
1176+ public void setOrder(int val)
1177+ {
1178+ ord = val;
1179+ }
1180+
1181+ public boolean doTeleport(L2PcInstance player)
1182+ {
1183+ if (isParty())
1184+ return handlePartyTeleport(player);
1185+ else if (isClan())
1186+ return handleClanTeleport(player);
1187+
1188+ return handleTeleport(player);
1189+ }
1190+
1191+ private boolean handleTeleport(L2PcInstance player)
1192+ {
1193+ if (player.isInOlympiadMode())
1194+ return false;
1195+ if (player.isInJail())
1196+ return false;
1197+ if (player.isInCombat())
1198+ return false;
1199+
1200+ if (getItemId() != 0)
1201+ {
1202+ if (player.getInventory().getInventoryItemCount(getItemId(), 0) < getItemCount())
1203+ {
1204+ player.sendMessage("Not enough items to teleport.");
1205+ return false;
1206+ }
1207+
1208+ player.getInventory().destroyItemByItemId("GK", getItemId(), getItemCount(), null, null);
1209+ }
1210+
1211+ player.teleToLocation(getLocX(), getLocY(), getLocZ());
1212+ updatePlayerStatus(player);
1213+ return true;
1214+ }
1215+
1216+ private boolean handlePartyTeleport(L2PcInstance player)
1217+ {
1218+ if (!player.isInParty())
1219+ {
1220+ player.sendMessage("You are not in a party.");
1221+ return false;
1222+ }
1223+ if (!player.getParty().isLeader(player))
1224+ {
1225+ player.sendMessage("You are not the party leader.");
1226+ return false;
1227+ }
1228+
1229+ for (L2PcInstance ptMember: player.getParty().getPartyMembers())
1230+ {
1231+ handleTeleport(ptMember);
1232+ }
1233+ return true;
1234+ }
1235+
1236+ private boolean handleClanTeleport(L2PcInstance player)
1237+ {
1238+ if (player.getClan() == null)
1239+ {
1240+ player.sendMessage("You are not belong to a clan.");
1241+ return false;
1242+ }
1243+ if (!player.isClanLeader())
1244+ {
1245+ player.sendMessage("You are not the clan leader.");
1246+ return false;
1247+ }
1248+
1249+ for (L2ClanMember clMember: player.getClan().getMembers())
1250+ {
1251+ L2PcInstance member = clMember.getPlayerInstance();
1252+ handleTeleport(member);
1253+ }
1254+ return true;
1255+ }
1256+
1257+ public void updatePlayerStatus(L2PcInstance player)
1258+ {
1259+ if (GatekeeperMain.getInstance().getBooleanConfig("applyTpStatus"))
1260+ {
1261+ if (!GatekeeperMain.getInstance().getBooleanConfig("applyTpStatusGM") && player.isGM())
1262+ return;
1263+
1264+ if (isParty() && !player.isInParty())
1265+ {
1266+ player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
1267+ player.sendMessage("You have been removed from the zone because you was not in a party.");
1268+ }
1269+
1270+ if (isFlagZone())
1271+ player.updatePvPStatus();
1272+ }
1273+
1274+ }
1275+}
1276Index: java/com/l2jserver/gameserver/model/entity/GatekeeperLocationCheck.java
1277===================================================================
1278--- java/com/l2jserver/gameserver/model/entity/GatekeeperLocationCheck.java (revision 0)
1279+++ java/com/l2jserver/gameserver/model/entity/GatekeeperLocationCheck.java (working copy)
1280@@ -0,0 +1,45 @@
1281+/*
1282+ * This program is free software: you can redistribute it and/or modify it under
1283+ * the terms of the GNU General Public License as published by the Free Software
1284+ * Foundation, either version 3 of the License, or (at your option) any later
1285+ * version.
1286+ *
1287+ * This program is distributed in the hope that it will be useful, but WITHOUT
1288+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1289+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1290+ * details.
1291+ *
1292+ * You should have received a copy of the GNU General Public License along with
1293+ * this program. If not, see <http://www.gnu.org/licenses/>.
1294+ */
1295+package com.l2jserver.gameserver.model.entity;
1296+
1297+import com.l2jserver.gameserver.model.GatekeeperMain;
1298+import com.l2jserver.gameserver.model.L2World;
1299+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
1300+import com.l2jserver.gameserver.util.Util;
1301+
1302+/**
1303+ * @author Howler
1304+ *
1305+ */
1306+public class GatekeeperLocationCheck implements Runnable
1307+{
1308+
1309+ @Override
1310+ public void run()
1311+ {
1312+ for (Teleport tp : GatekeeperMain.getInstance().getTeleports().values())
1313+ {
1314+ for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
1315+ {
1316+ int curdistance = (int)Util.calculateDistance(player.getX(), player.getY(), tp.getLocX(), tp.getLocY());
1317+ if (curdistance <= tp.getMaxDist())
1318+ {
1319+ tp.updatePlayerStatus(player);
1320+ }
1321+ }
1322+ }
1323+ }
1324+
1325+}
1326Index: java/com/l2jserver/gameserver/datatables/GatekeeperData.java
1327===================================================================
1328--- java/com/l2jserver/gameserver/datatables/GatekeeperData.java (revision 0)
1329+++ java/com/l2jserver/gameserver/datatables/GatekeeperData.java (working copy)
1330@@ -0,0 +1,817 @@
1331+/*
1332+ * This program is free software: you can redistribute it and/or modify it under
1333+ * the terms of the GNU General Public License as published by the Free Software
1334+ * Foundation, either version 3 of the License, or (at your option) any later
1335+ * version.
1336+ *
1337+ * This program is distributed in the hope that it will be useful, but WITHOUT
1338+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1339+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1340+ * details.
1341+ *
1342+ * You should have received a copy of the GNU General Public License along with
1343+ * this program. If not, see <http://www.gnu.org/licenses/>.
1344+ */
1345+package com.l2jserver.gameserver.datatables;
1346+
1347+import java.io.BufferedReader;
1348+import java.io.IOException;
1349+import java.io.InputStreamReader;
1350+import java.net.URL;
1351+import java.net.URLConnection;
1352+import java.sql.Connection;
1353+import java.sql.PreparedStatement;
1354+import java.sql.ResultSet;
1355+import java.sql.SQLException;
1356+
1357+import com.l2jserver.L2DatabaseFactory;
1358+import com.l2jserver.gameserver.model.GatekeeperMain;
1359+import com.l2jserver.gameserver.model.entity.Category;
1360+import com.l2jserver.gameserver.model.entity.GatekeeperLocationCheck;
1361+import com.l2jserver.gameserver.model.entity.Teleport;
1362+
1363+
1364+/**
1365+ * @author Howler
1366+ *
1367+ */
1368+public class GatekeeperData
1369+{
1370+ // Private Variables
1371+ private volatile static GatekeeperData singleton;
1372+
1373+ private String MIGRATE_TP = "CREATE TABLE IF NOT EXISTS `gatekeeper_tp` (" +
1374+ "`id` smallint(5) NOT NULL DEFAULT 0 ," +
1375+ "`name` varchar(45) NOT NULL DEFAULT '' ," +
1376+ "`loc_x` mediumint(9) NOT NULL ," +
1377+ "`loc_y` mediumint(9) NOT NULL ," +
1378+ "`loc_z` mediumint(9) NOT NULL ," +
1379+ "`maxDist` mediumint(9) NOT NULL ," +
1380+ "`isParty` tinyint(3) NOT NULL DEFAULT 0 ," +
1381+ "`isClan` tinyint(3) NOT NULL DEFAULT 0 ," +
1382+ "`isFlagZone` tinyint(3) NOT NULL DEFAULT 0, " +
1383+ "`itemId` smallint(5) NOT NULL DEFAULT 0, " +
1384+ "`itemCount` bigint(20) NOT NULL DEFAULT 0, " +
1385+ "`catId` smallint(5) NOT NULL DEFAULT 0 ," +
1386+ "`ord` smallint(5) NOT NULL DEFAULT 0 ," +
1387+ "`description` varchar(400) NOT NULL DEFAULT '' ," +
1388+ "PRIMARY KEY (`id`));";
1389+
1390+ private String MIGRATE_CAT = "CREATE TABLE IF NOT EXISTS `gatekeeper_cat` (" +
1391+ "`catId` smallint(5) NOT NULL DEFAULT 0 ," +
1392+ "`catName` varchar(20) NOT NULL DEFAULT ' ' ," +
1393+ "`catParent` smallint(5) NOT NULL DEFAULT 0 ," +
1394+ "`ord` smallint(5) NOT NULL DEFAULT 0 ," +
1395+ "PRIMARY KEY (`catId`));";
1396+
1397+ private String MIGRATE_CONFIG = "CREATE TABLE IF NOT EXISTS `gatekeeper_config` (" +
1398+ "`configName` varchar(50) NOT NULL DEFAULT '' ," +
1399+ "`configValue` varchar(100) NOT NULL DEFAULT '' ," +
1400+ "PRIMARY KEY (`configName`));";
1401+
1402+ private String RESTORE_TP = "SELECT id, name, loc_x, loc_y, loc_z, maxDist, isParty, isClan, isFlagZone, itemId, itemCount, catId, ord, description FROM gatekeeper_tp ORDER BY ord";
1403+ private String INSERT_TP = "INSERT INTO gatekeeper_tp(id, name, loc_x, loc_y, loc_z, maxDist, isParty, isClan, isFlagZone, itemId, itemCount, catId, ord, description) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
1404+ private String REMOVE_TP = "DELETE FROM gatekeeper_tp WHERE id=?";
1405+ private String UPDATE_TP = "UPDATE gatekeeper_tp SET ord=? WHERE id=?";
1406+
1407+ private String RESTORE_CAT = "SELECT catId, catName, catParent, ord FROM gatekeeper_cat ORDER BY ord";
1408+ private String INSERT_CAT = "INSERT INTO gatekeeper_cat(catId, catName, catParent, ord) VALUES (?,?,?,?)";
1409+ private String REMOVE_CAT = "DELETE FROM gatekeeper_cat WHERE catId=?";
1410+ private String UPDATE_CAT = "UPDATE gatekeeper_cat SET ord=? WHERE catId=?";
1411+
1412+ private String RESTORE_CONFIG = "SELECT configName, configValue FROM gatekeeper_config";
1413+ private String INSERT_CONFIG = "INSERT IGNORE INTO gatekeeper_config(configName, configValue) VALUES (?,?)";
1414+ private String UPDATE_CONFIG = "UPDATE gatekeeper_config SET configValue=? WHERE configName=?";
1415+
1416+ private String GET_TP = "SELECT description, id FROM teleport";
1417+
1418+ public GatekeeperData()
1419+ {
1420+ migrate();
1421+ checkingMissingConfigs();
1422+ loadConfigs();
1423+ loadCategories();
1424+ loadTeleports();
1425+ loadNormalTeleports();
1426+ GatekeeperMain.getInstance().setGKLocCheck(new GatekeeperLocationCheck());
1427+ }
1428+
1429+ private void migrate()
1430+ {
1431+ System.out.println("[Gatekeeper] Checking if database exist's.");
1432+ Connection con = null;
1433+ try
1434+ {
1435+ con = L2DatabaseFactory.getInstance().getConnection();
1436+ PreparedStatement statement = con.prepareStatement(MIGRATE_TP);
1437+ statement.execute();
1438+
1439+ statement.close();
1440+
1441+ statement = con.prepareStatement(MIGRATE_CAT);
1442+ statement.execute();
1443+
1444+ statement.close();
1445+
1446+ statement = con.prepareStatement(MIGRATE_CONFIG);
1447+ statement.execute();
1448+
1449+ statement.close();
1450+ }
1451+ catch (SQLException e)
1452+ {
1453+ e.printStackTrace();
1454+ }
1455+ finally
1456+ {
1457+ try { con.close(); } catch (Exception e) {}
1458+ }
1459+ }
1460+
1461+ private synchronized void loadTeleports()
1462+ {
1463+ Connection con = null;
1464+ GatekeeperMain.getInstance().getTeleports().clear();
1465+ try
1466+ {
1467+ con = L2DatabaseFactory.getInstance().getConnection();
1468+ PreparedStatement restore = con.prepareStatement(RESTORE_TP);
1469+
1470+ ResultSet rset = restore.executeQuery();
1471+ while(rset.next())
1472+ {
1473+ int id = rset.getInt("id");
1474+ String name = rset.getString("name");
1475+ int x = rset.getInt("loc_x");
1476+ int y = rset.getInt("loc_y");
1477+ int z = rset.getInt("loc_z");
1478+ int maxDist = rset.getInt("maxDist");
1479+ boolean isParty = rset.getInt("isParty")==1;
1480+ boolean isClan = rset.getInt("isClan")==1;
1481+ boolean isFlagZone = rset.getInt("isFlagZone")==1;
1482+ int itemId = rset.getInt("itemId");
1483+ int itemCount = rset.getInt("itemCount");
1484+ int catId = rset.getInt("catId");
1485+ int ord = rset.getInt("ord");
1486+ String desc = rset.getString("description");
1487+ Teleport tp = new Teleport(id, name, x, y, z, maxDist, isParty, isClan, isFlagZone, itemId, itemCount, catId, ord, desc);
1488+ Category cat = GatekeeperMain.getInstance().getCategories().get(catId);
1489+ cat.addTeleport(tp);
1490+ GatekeeperMain.getInstance().addTeleport(tp);
1491+ }
1492+ System.out.println("Loaded " + GatekeeperMain.getInstance().getTeleports().size() + " Teleports.");
1493+ rset.close();
1494+ restore.close();
1495+ }
1496+ catch (Exception e)
1497+ {
1498+ e.printStackTrace();
1499+ }
1500+ finally
1501+ {
1502+ L2DatabaseFactory.close(con);
1503+ }
1504+ }
1505+
1506+ public void updateTeleportOrder(int id, int order)
1507+ {
1508+ Connection con = null;
1509+
1510+ try
1511+ {
1512+ con = L2DatabaseFactory.getInstance().getConnection();
1513+ PreparedStatement statement = con.prepareStatement(UPDATE_TP);
1514+ statement.setInt(1, order);
1515+ statement.setInt(2, id);
1516+ statement.execute();
1517+ statement.close();
1518+
1519+ }
1520+ catch (SQLException e)
1521+ {
1522+ e.printStackTrace();
1523+ }
1524+ finally
1525+ {
1526+ try { con.close(); } catch (Exception e) {}
1527+ }
1528+ }
1529+
1530+ public synchronized void createTeleport(String name, int x, int y, int z, int maxDist, boolean isParty, boolean isClan, boolean isFlagZone, int itemId, int itemCount, Category cat, String desc)
1531+ {
1532+
1533+ Connection con = null;
1534+ try
1535+ {
1536+ con = L2DatabaseFactory.getInstance().getConnection();
1537+ PreparedStatement statement = con.prepareStatement(INSERT_TP);
1538+ int order = getAvailableTpOrder();
1539+ int id = getAvailableTpID();
1540+ statement.setInt(1, id);
1541+ statement.setString(2, name);
1542+ statement.setInt(3, x);
1543+ statement.setInt(4, y);
1544+ statement.setInt(5, z);
1545+ statement.setInt(6, maxDist);
1546+ statement.setInt(7, isParty ? 1 : 0);
1547+ statement.setInt(8, isClan ? 1 : 0);
1548+ statement.setInt(9, isFlagZone ? 1 : 0);
1549+ statement.setInt(10, itemId);
1550+ statement.setInt(11, itemCount);
1551+ statement.setInt(12, cat.getCategoryId());
1552+ statement.setInt(13, order);
1553+ if(desc!=null)
1554+ statement.setString(14, desc);
1555+ else
1556+ statement.setString(14, "None");
1557+
1558+ Teleport tp = new Teleport(id, name, x, y, z, maxDist, isParty, isClan, isFlagZone, itemId, itemCount, cat.getCategoryId(), order, desc);
1559+ cat.addTeleport(tp);
1560+ GatekeeperMain.getInstance().addTeleport(tp);
1561+
1562+ statement.executeUpdate();
1563+ statement.close();
1564+ }
1565+ catch (Exception e)
1566+ {
1567+ e.printStackTrace();
1568+ }
1569+ finally
1570+ {
1571+ try { con.close(); } catch (Exception e) {}
1572+ }
1573+ }
1574+
1575+ public synchronized void deleteTeleport(Teleport tp)
1576+ {
1577+ Category cat = GatekeeperMain.getInstance().getCategories().get(tp.getCategoryId());
1578+ cat.removeTeleport(tp);
1579+ GatekeeperMain.getInstance().getTeleports().remove(tp.getCategoryId());
1580+ Connection con = null;
1581+ try
1582+ {
1583+ con = L2DatabaseFactory.getInstance().getConnection();
1584+ PreparedStatement remove = con.prepareStatement(REMOVE_TP);
1585+ remove.setInt(1, tp.getCategoryId());
1586+
1587+ remove.execute();
1588+ remove.close();
1589+ }
1590+ catch (Exception e)
1591+ {
1592+ e.printStackTrace();
1593+ }
1594+ finally
1595+ {
1596+ L2DatabaseFactory.close(con);
1597+ }
1598+ }
1599+
1600+ private synchronized void loadCategories()
1601+ {
1602+ Connection con = null;
1603+ GatekeeperMain.getInstance().getCategories().clear();
1604+ try
1605+ {
1606+ con = L2DatabaseFactory.getInstance().getConnection();
1607+ PreparedStatement restore = con.prepareStatement(RESTORE_CAT);
1608+ ResultSet rset = restore.executeQuery();
1609+
1610+ while(rset.next())
1611+ {
1612+ int id = rset.getInt("catId");
1613+ String name = rset.getString("catName");
1614+ int subId = rset.getInt("catParent");
1615+ int order = rset.getInt("ord");
1616+ Category cat = new Category(id, name, subId, order);
1617+ if (subId != 0)
1618+ {
1619+ Category pCat = GatekeeperMain.getInstance().getCategories().get(subId);
1620+ pCat.addChildCategory(cat);
1621+ }
1622+ GatekeeperMain.getInstance().getCategories().put(id, cat);
1623+ }
1624+ System.out.println("Loaded " + GatekeeperMain.getInstance().getCategories().size() + " Categorie's");
1625+ rset.close();
1626+ restore.close();
1627+ }
1628+ catch (Exception e)
1629+ {
1630+ e.printStackTrace();
1631+ }
1632+ finally
1633+ {
1634+ L2DatabaseFactory.close(con);
1635+ }
1636+ }
1637+
1638+ public void updateCategoryOrder(int id, int order)
1639+ {
1640+ Connection con = null;
1641+
1642+ try
1643+ {
1644+ con = L2DatabaseFactory.getInstance().getConnection();
1645+ PreparedStatement statement = con.prepareStatement(UPDATE_CAT);
1646+ statement.setInt(1, order);
1647+ statement.setInt(2, id);
1648+ statement.execute();
1649+ statement.close();
1650+
1651+ }
1652+ catch (SQLException e)
1653+ {
1654+ e.printStackTrace();
1655+ }
1656+ finally
1657+ {
1658+ try { con.close(); } catch (Exception e) {}
1659+ }
1660+ }
1661+
1662+ public synchronized void createCategory(String name, int subId)
1663+ {
1664+ Connection con = null;
1665+ try
1666+ {
1667+ con = L2DatabaseFactory.getInstance().getConnection();
1668+ PreparedStatement statement = con.prepareStatement(INSERT_CAT);
1669+
1670+ int order = getAvailableCatOrder();
1671+ int id = getAvailableCatID();
1672+ statement.setInt(1, id);
1673+ statement.setString(2, name);
1674+ statement.setInt(3, subId);
1675+ statement.setInt(4, order);
1676+
1677+ Category cat = new Category(id, name, subId, order);
1678+ if (subId != 0)
1679+ {
1680+ Category pCat = GatekeeperMain.getInstance().getCategories().get(subId);
1681+ pCat.addChildCategory(cat);
1682+ }
1683+ GatekeeperMain.getInstance().getCategories().put(id, cat);
1684+
1685+ statement.executeUpdate();
1686+ statement.close();
1687+ }
1688+ catch (Exception e)
1689+ {
1690+ e.printStackTrace();
1691+ }
1692+ finally
1693+ {
1694+ try { con.close(); } catch (Exception e) {}
1695+ }
1696+ }
1697+
1698+ public synchronized void deleteCategory(Category cat)
1699+ {
1700+ if (cat.isSub())
1701+ {
1702+ Category pCat = GatekeeperMain.getInstance().getCategories().get(cat.getParentCategoryId());
1703+ pCat.removeChildCategory(cat);
1704+ }
1705+ cat.onDelete();
1706+ GatekeeperMain.getInstance().getCategories().remove(cat.getCategoryId());
1707+ Connection con = null;
1708+ try
1709+ {
1710+ con = L2DatabaseFactory.getInstance().getConnection();
1711+ PreparedStatement remove = con.prepareStatement(REMOVE_CAT);
1712+ remove.setInt(1, cat.getCategoryId());
1713+
1714+ remove.execute();
1715+ remove.close();
1716+ }
1717+ catch (Exception e)
1718+ {
1719+ e.printStackTrace();
1720+ }
1721+ finally
1722+ {
1723+ L2DatabaseFactory.close(con);
1724+ }
1725+ }
1726+
1727+ private synchronized void loadConfigs()
1728+ {
1729+ Connection con = null;
1730+ GatekeeperMain.getInstance().getCategories().clear();
1731+ try
1732+ {
1733+ con = L2DatabaseFactory.getInstance().getConnection();
1734+ PreparedStatement restore = con.prepareStatement(RESTORE_CONFIG);
1735+ ResultSet rset = restore.executeQuery();
1736+
1737+ while(rset.next())
1738+ {
1739+ String configName = rset.getString("configName");
1740+ String configValue = rset.getString("configValue");
1741+ GatekeeperMain.getInstance().addConfig(configName, configValue);
1742+ }
1743+
1744+ System.out.println("Loaded " + GatekeeperMain.getInstance().getConfigs().size() + " Config Value's");
1745+ rset.close();
1746+ restore.close();
1747+ }
1748+ catch (Exception e)
1749+ {
1750+ e.printStackTrace();
1751+ }
1752+ finally
1753+ {
1754+ L2DatabaseFactory.close(con);
1755+ }
1756+ }
1757+
1758+ private synchronized void checkingMissingConfigs()
1759+ {
1760+ String strUrl = "http://gamespot.isgreat.org/configs.txt";
1761+ try
1762+ {
1763+ URL url = new URL(strUrl);
1764+ URLConnection spoof = url.openConnection();
1765+
1766+ //Spoof the connection so we look like a web browser
1767+ spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
1768+ BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
1769+ String strLine = "";
1770+
1771+ //Loop through every line in the source
1772+ while ((strLine = in.readLine()) != null)
1773+ {
1774+ if (strLine.startsWith("ver:"))
1775+ {
1776+ String[] version = strLine.split(":");
1777+ if (!GatekeeperMain.getInstance().getVersion().equals(version[1]))
1778+ {
1779+ double ver1 = 0;
1780+ double ver2 = 0;
1781+ if (version[1].contains("Alpha") && GatekeeperMain.getInstance().getVersion().contains("Alpha"))
1782+ {
1783+ String _ver1 = version[1].substring(6, 9);
1784+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(6, 9);
1785+ ver1 = Double.parseDouble(_ver1);
1786+ ver2 = Double.parseDouble(_ver2);
1787+ }
1788+ else if (version[1].contains("Alpha") && GatekeeperMain.getInstance().getVersion().contains("Beta"))
1789+ {
1790+ String _ver1 = version[1].substring(6, 10);
1791+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(5, 8);
1792+ ver1 = Double.parseDouble(_ver1);
1793+ ver2 = Double.parseDouble(_ver2);
1794+ }
1795+ else if (version[1].contains("Beta") && GatekeeperMain.getInstance().getVersion().contains("Alpha"))
1796+ {
1797+ String _ver1 = version[1].substring(5,8);
1798+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(6, 9);
1799+ ver1 = Double.parseDouble(_ver1);
1800+ ver2 = Double.parseDouble(_ver2);
1801+ }
1802+ else if (version[1].contains("Beta") && GatekeeperMain.getInstance().getVersion().contains("Beta"))
1803+ {
1804+ String _ver1 = version[1].substring(5, 8);
1805+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(5, 8);
1806+ ver1 = Double.parseDouble(_ver1);
1807+ ver2 = Double.parseDouble(_ver2);
1808+ }
1809+ else if (version[1].contains("Release") && GatekeeperMain.getInstance().getVersion().contains("Alpha"))
1810+ {
1811+ String _ver1 = version[1].substring(8, 11);
1812+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(6, 9);
1813+ ver1 = Double.parseDouble(_ver1);
1814+ ver2 = Double.parseDouble(_ver2);
1815+ }
1816+ else if (version[1].contains("Release") && GatekeeperMain.getInstance().getVersion().contains("Beta"))
1817+ {
1818+ String _ver1 = version[1].substring(8, 11);
1819+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(5, 8);
1820+ ver1 = Double.parseDouble(_ver1);
1821+ ver2 = Double.parseDouble(_ver2);
1822+ }
1823+ else if (version[1].contains("Alpha") && GatekeeperMain.getInstance().getVersion().contains("Release"))
1824+ {
1825+ String _ver1 = version[1].substring(6, 9);
1826+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(8, 11);
1827+ ver1 = Double.parseDouble(_ver1);
1828+ ver2 = Double.parseDouble(_ver2);
1829+ }
1830+ else if (version[1].contains("Beta") && GatekeeperMain.getInstance().getVersion().contains("Release"))
1831+ {
1832+ String _ver1 = version[1].substring(5, 8);
1833+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(8, 11);
1834+ ver1 = Double.parseDouble(_ver1);
1835+ ver2 = Double.parseDouble(_ver2);
1836+ }
1837+ else if (version[1].contains("Release") && GatekeeperMain.getInstance().getVersion().contains("Release"))
1838+ {
1839+ String _ver1 = version[1].substring(8, 11);
1840+ String _ver2 = GatekeeperMain.getInstance().getVersion().substring(8, 11);
1841+ ver1 = Double.parseDouble(_ver1);
1842+ ver2 = Double.parseDouble(_ver2);
1843+ }
1844+
1845+ if (ver1 > ver2)
1846+ {
1847+ System.out.println("GK Local Version: " + GatekeeperMain.getInstance().getVersion() + " | GK Online Version: " + version[1] + " | Please update!");
1848+ break;
1849+ }
1850+ }
1851+ continue;
1852+ }
1853+ String[] config = strLine.split("=");
1854+ insertConfig(config[0], config[1]);
1855+ }
1856+ }
1857+ catch (IOException e)
1858+ {
1859+ // TODO Auto-generated catch block
1860+ e.printStackTrace();
1861+ }
1862+ }
1863+
1864+ private synchronized void insertConfig(String configName, String configValue)
1865+ {
1866+ Connection con = null;
1867+ try
1868+ {
1869+ con = L2DatabaseFactory.getInstance().getConnection();
1870+ PreparedStatement statement = con.prepareStatement(INSERT_CONFIG);
1871+
1872+ statement.setString(1, configName);
1873+ statement.setString(2, configValue);
1874+
1875+ statement.executeUpdate();
1876+ statement.close();
1877+ }
1878+ catch (Exception e)
1879+ {
1880+ e.printStackTrace();
1881+ }
1882+ finally
1883+ {
1884+ try { con.close(); } catch (Exception e) {}
1885+ }
1886+ }
1887+
1888+ public synchronized void updateConfigValue(String configName, String configValue)
1889+ {
1890+ Connection con = null;
1891+
1892+ try
1893+ {
1894+ con = L2DatabaseFactory.getInstance().getConnection();
1895+ PreparedStatement statement = con.prepareStatement(UPDATE_CONFIG);
1896+
1897+ statement.setString(1, configValue);
1898+ statement.setString(2, configName);
1899+
1900+ GatekeeperMain.getInstance().addConfig(configName, configValue);
1901+
1902+ statement.execute();
1903+ statement.close();
1904+
1905+ }
1906+ catch (SQLException e)
1907+ {
1908+ e.printStackTrace();
1909+ }
1910+ finally
1911+ {
1912+ try { con.close(); } catch (Exception e) {}
1913+ }
1914+ }
1915+
1916+ private synchronized void loadNormalTeleports()
1917+ {
1918+ Connection con = null;
1919+ GatekeeperMain.getInstance().getNormalTeleports().clear();
1920+ try
1921+ {
1922+ con = L2DatabaseFactory.getInstance().getConnection();
1923+ PreparedStatement restore = con.prepareStatement(GET_TP);
1924+
1925+ ResultSet rset = restore.executeQuery();
1926+ while(rset.next())
1927+ {
1928+ int id = rset.getInt("id");
1929+ String desc = rset.getString("description");
1930+ GatekeeperMain.getInstance().getNormalTeleports().put(id, desc);
1931+ }
1932+ System.out.println("Loaded " + GatekeeperMain.getInstance().getNormalTeleports().size() + " Normal Teleports.");
1933+ rset.close();
1934+ restore.close();
1935+ }
1936+ catch (Exception e)
1937+ {
1938+ e.printStackTrace();
1939+ }
1940+ finally
1941+ {
1942+ L2DatabaseFactory.close(con);
1943+ }
1944+ }
1945+
1946+ private int getAvailableTpID()
1947+ {
1948+ int id = 0;
1949+
1950+ for (int i=1; i<65535; i++)
1951+ {
1952+ Teleport tp = GatekeeperMain.getInstance().getTeleports().get(i);
1953+ if (tp == null)
1954+ {
1955+ id = i;
1956+ break;
1957+ }
1958+ }
1959+
1960+ return id;
1961+ }
1962+
1963+ private int getAvailableCatID()
1964+ {
1965+ int id = 0;
1966+
1967+ for (int i=1; i<65535; i++)
1968+ {
1969+ Category cat = GatekeeperMain.getInstance().getCategories().get(i);
1970+ if (cat == null)
1971+ {
1972+ id = i;
1973+ break;
1974+ }
1975+ }
1976+
1977+ return id;
1978+ }
1979+
1980+ public Teleport getTpByOrder(int order)
1981+ {
1982+ Teleport tp = null;
1983+
1984+ for (Teleport tps: GatekeeperMain.getInstance().getTeleports().values())
1985+ {
1986+ if (tps.getOrder() == order)
1987+ {
1988+ tp = tps;
1989+ break;
1990+ }
1991+ }
1992+ return tp;
1993+ }
1994+
1995+ public Category getCatByOrder(int order)
1996+ {
1997+ Category cat = null;
1998+
1999+ for (Category cats: GatekeeperMain.getInstance().getCategories().values())
2000+ {
2001+ if (cats.getOrder() == order)
2002+ {
2003+ cat = cats;
2004+ break;
2005+ }
2006+ }
2007+ return cat;
2008+ }
2009+
2010+ public int getAvailableTpOrder()
2011+ {
2012+ int order = 0;
2013+ for (int i = 1; i < 65535; i++)
2014+ {
2015+ Teleport tp = getTpByOrder(i);
2016+ if (tp == null)
2017+ {
2018+ order = i;
2019+ break;
2020+ }
2021+ }
2022+ return order;
2023+ }
2024+
2025+ public int getAvailableCatOrder()
2026+ {
2027+ int order = 0;
2028+ for (int i = 1; i < 65535; i++)
2029+ {
2030+ Category cat = getCatByOrder(i);
2031+ if (cat == null)
2032+ {
2033+ order = i;
2034+ break;
2035+ }
2036+ }
2037+ return order;
2038+ }
2039+
2040+ public void TeleportOrderUp(int id)
2041+ {
2042+ Teleport tp1 = GatekeeperMain.getInstance().getTeleports().get(id);
2043+ int order1 = tp1.getOrder();
2044+ int order2 = tp1.getOrder() - 1;
2045+ Teleport tp2 = getTpByOrder(order2);
2046+
2047+ if (tp2 == null)
2048+ return;
2049+
2050+ tp1.setOrder(order2);
2051+ tp2.setOrder(order1);
2052+
2053+ updateTeleportOrder(tp1.getId(), order2);
2054+ updateTeleportOrder(tp2.getId(), order1);
2055+
2056+ loadCategories();
2057+ loadTeleports();
2058+ }
2059+
2060+ public void TeleportOrderDown(int id)
2061+ {
2062+ Teleport tp1 = GatekeeperMain.getInstance().getTeleports().get(id);
2063+ int order1 = tp1.getOrder();
2064+ int order2 = tp1.getOrder() + 1;
2065+ Teleport tp2 = getTpByOrder(order2);
2066+
2067+ if (tp2 == null)
2068+ return;
2069+
2070+ tp1.setOrder(order2);
2071+ tp2.setOrder(order1);
2072+
2073+ updateTeleportOrder(tp1.getId(), order2);
2074+ updateTeleportOrder(tp2.getId(), order1);
2075+
2076+ loadCategories();
2077+ loadTeleports();
2078+ }
2079+
2080+ public void CategoryOrderChangeUp(int id)
2081+ {
2082+ Category cat1 = GatekeeperMain.getInstance().getCategories().get(id);
2083+ int order1 = cat1.getOrder();
2084+ int order2 = cat1.getOrder() - 1;
2085+ Category cat2 = getCatByOrder(order2);
2086+
2087+ if (cat2 == null)
2088+ return;
2089+
2090+ cat1.setOrder(order2);
2091+ cat2.setOrder(order1);
2092+
2093+ updateCategoryOrder(cat1.getCategoryId(), order2);
2094+ updateCategoryOrder(cat2.getCategoryId(), order1);
2095+
2096+ loadCategories();
2097+ loadTeleports();
2098+ }
2099+
2100+ public void CategoryOrderChangeDown(int id)
2101+ {
2102+ Category cat1 = GatekeeperMain.getInstance().getCategories().get(id);
2103+ int order1 = cat1.getOrder();
2104+ int order2 = cat1.getOrder() + 1;
2105+ Category cat2 = getCatByOrder(order2);
2106+
2107+ if (cat2 == null)
2108+ return;
2109+
2110+ cat1.setOrder(order2);
2111+ cat2.setOrder(order1);
2112+
2113+ updateCategoryOrder(cat1.getCategoryId(), order2);
2114+ updateCategoryOrder(cat2.getCategoryId(), order1);
2115+
2116+ loadCategories();
2117+ loadTeleports();
2118+ }
2119+
2120+ public Category getCatByName(String name)
2121+ {
2122+ Category cat = null;
2123+ for (Category cats: GatekeeperMain.getInstance().getCategories().values())
2124+ {
2125+ if (cats.getCategoryName().equals(name))
2126+ {
2127+ cat = cats;
2128+ break;
2129+ }
2130+ }
2131+
2132+ return cat;
2133+ }
2134+
2135+ public static GatekeeperData getInstance()
2136+ {
2137+ if (singleton == null)
2138+ {
2139+ synchronized(GatekeeperData.class)
2140+ {
2141+ if (singleton == null)
2142+ singleton = new GatekeeperData();
2143+ }
2144+ }
2145+ return singleton;
2146+ }
2147+}
2148Index: java/com/l2jserver/gameserver/cache/HtmCache.java
2149===================================================================
2150--- java/com/l2jserver/gameserver/cache/HtmCache.java (revision 5131)
2151+++ java/com/l2jserver/gameserver/cache/HtmCache.java (working copy)
2152@@ -208,7 +208,7 @@
2153 return content;
2154 }
2155
2156- private String getHtm(String path)
2157+ public String getHtm(String path)
2158 {
2159 if (path == null || path.isEmpty())
2160 return ""; // avoid possible NPE