Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2CastleChamberlainInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2CastleChamberlainInstance.java (revision 343)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2CastleChamberlainInstance.java (working copy)
- @@ -20,7 +20,6 @@
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- -import java.util.List;
- import java.util.NoSuchElementException;
- import java.util.StringTokenizer;
- @@ -59,9 +58,9 @@
- protected static final int COND_ALL_FALSE = 0;
- protected static final int COND_BUSY_BECAUSE_OF_SIEGE = 1;
- protected static final int COND_OWNER = 2;
- - private int _preDay;
- - private int _preHour;
- + private int _preHour = 6;
- +
- public L2CastleChamberlainInstance(int objectId, L2NpcTemplate template)
- {
- super(objectId, template);
- @@ -105,6 +104,8 @@
- val = st.nextToken();
- }
- + final Castle castle = getCastle();
- +
- if (actualCommand.equalsIgnoreCase("banish_foreigner"))
- {
- if (!validatePrivileges(player, L2Clan.CP_CS_DISMISS))
- @@ -1129,93 +1130,55 @@
- doTeleport(player, whereTo);
- return;
- }
- - else if (actualCommand.equalsIgnoreCase("siege_change")) // siege day set
- + else if (actualCommand.equalsIgnoreCase("siege_change")) // set siege time
- {
- - if (Config.CL_SET_SIEGE_TIME_LIST.isEmpty())
- + if (!validatePrivileges(player, L2Clan.CP_CS_MANAGE_SIEGE))
- {
- + return;
- + }
- +
- + if (castle.getSiege().getTimeRegistrationOverDate().getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
- + {
- NpcHtmlMessage html = new NpcHtmlMessage(1);
- - html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/chamberlain-noadmin.htm");
- + html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime1.htm");
- sendHtmlMessage(player, html);
- }
- - else if (player.isClanLeader())
- + else if (castle.getSiege().getIsTimeRegistrationOver())
- {
- - if (getCastle().getSiege().getTimeRegistrationOverDate().getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
- - {
- - NpcHtmlMessage html = new NpcHtmlMessage(1);
- - html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime1.htm");
- - sendHtmlMessage(player, html);
- - }
- - else if (getCastle().getSiege().getIsTimeRegistrationOver())
- - {
- - NpcHtmlMessage html = new NpcHtmlMessage(1);
- - html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime2.htm");
- - sendHtmlMessage(player, html);
- - }
- - else
- - {
- - NpcHtmlMessage html = new NpcHtmlMessage(1);
- - html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime3.htm");
- - html.replace("%time%", String.valueOf(getCastle().getSiegeDate().getTime()));
- - sendHtmlMessage(player, html);
- - }
- + NpcHtmlMessage html = new NpcHtmlMessage(1);
- + html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime2.htm");
- + sendHtmlMessage(player, html);
- }
- else
- {
- NpcHtmlMessage html = new NpcHtmlMessage(1);
- - html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/chamberlain-noprivs.htm");
- + html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime3.htm");
- sendHtmlMessage(player, html);
- }
- - return;
- }
- else if (actualCommand.equalsIgnoreCase("siege_time_set")) // set preDay
- {
- - boolean isAfternoon = Config.SIEGE_HOUR_LIST_MORNING.isEmpty();
- switch (Integer.parseInt(val))
- {
- - case 0:
- - case 4:
- - break;
- case 1:
- - _preDay = Integer.parseInt(st.nextToken());
- - break;
- - case 2:
- - isAfternoon = Boolean.parseBoolean(st.nextToken());
- - break;
- - case 3:
- _preHour = Integer.parseInt(st.nextToken());
- break;
- +
- default:
- break;
- }
- - NpcHtmlMessage html = getNextSiegeTimePage(player.getHtmlPrefix(), Integer.parseInt(val), isAfternoon);
- - if (html == null)
- + if (_preHour != 6)
- {
- - if (Config.CL_SET_SIEGE_TIME_LIST.contains("day"))
- - {
- - getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, _preDay);
- - }
- - else
- - {
- - getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
- - }
- - if (Config.CL_SET_SIEGE_TIME_LIST.contains("hour"))
- - {
- - getCastle().getSiegeDate().set(Calendar.HOUR_OF_DAY, _preHour);
- - }
- - if (Config.CL_SET_SIEGE_TIME_LIST.contains("minute"))
- - {
- - getCastle().getSiegeDate().set(Calendar.MINUTE, Integer.parseInt(st.nextToken()));
- - }
- + castle.getSiegeDate().set(Calendar.HOUR_OF_DAY, _preHour + 12);
- +
- // now store the changed time and finished next Siege Time registration
- - getCastle().getSiege().endTimeRegistration(false);
- -
- - html = new NpcHtmlMessage(1);
- - html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/siegetime8.htm");
- - html.replace("%time%", String.valueOf(getCastle().getSiegeDate().getTime()));
- + castle.getSiege().endTimeRegistration(false);
- + sendHtmlMessage(player, "data/html/chamberlain/siegetime8.htm");
- + return;
- }
- - sendHtmlMessage(player, html);
- - return;
- +
- + sendHtmlMessage(player, "data/html/chamberlain/siegetime6.htm");
- }
- else if (actualCommand.equals("give_crown"))
- {
- @@ -1352,80 +1315,13 @@
- }
- }
- - private NpcHtmlMessage getNextSiegeTimePage(String htmlPrefix, int now, boolean isAfternoon)
- - {
- - NpcHtmlMessage ret = new NpcHtmlMessage(1);
- - if ((now == 0) && Config.CL_SET_SIEGE_TIME_LIST.contains("day"))
- - {
- - ret.setFile(htmlPrefix, "data/html/chamberlain/siegetime4.htm");
- - return ret;
- - }
- - if ((now < 3) && Config.CL_SET_SIEGE_TIME_LIST.contains("hour"))
- - {
- - switch (now)
- - {
- - case 0:
- - case 1:
- - if (!Config.SIEGE_HOUR_LIST_MORNING.isEmpty() && !Config.SIEGE_HOUR_LIST_AFTERNOON.isEmpty())
- - {
- - ret.setFile(htmlPrefix, "data/html/chamberlain/siegetime5.htm");
- - return ret;
- - }
- - case 2:
- - ret.setFile(htmlPrefix, "data/html/chamberlain/siegetime6.htm");
- - List<Integer> list;
- - int inc = 0;
- - String ampm = "";
- -
- - if (!isAfternoon)
- - {
- - if (Config.SIEGE_HOUR_LIST_AFTERNOON.isEmpty())
- - {
- - ampm = "AM";
- - }
- - list = Config.SIEGE_HOUR_LIST_MORNING;
- - }
- - else
- - {
- - if (Config.SIEGE_HOUR_LIST_MORNING.isEmpty())
- - {
- - ampm = "PM";
- - }
- - inc = 12;
- - list = Config.SIEGE_HOUR_LIST_AFTERNOON;
- - }
- -
- - final StringBuilder tList = new StringBuilder(list.size() * 50);
- - for (Integer hour : list)
- - {
- - if (hour == 0)
- - {
- - StringUtil.append(tList, "<a action=\"bypass -h npc_%objectId%_siege_time_set 3 ", String.valueOf(hour + inc), "\">", String.valueOf(hour + 12), ":00 ", ampm, "</a><br>");
- - }
- - else
- - {
- - StringUtil.append(tList, "<a action=\"bypass -h npc_%objectId%_siege_time_set 3 ", String.valueOf(hour + inc), "\">", String.valueOf(hour), ":00 ", ampm, "</a><br>");
- - }
- - }
- - ret.replace("%links%", tList.toString());
- - }
- - return ret;
- - }
- - if ((now < 4) && Config.CL_SET_SIEGE_TIME_LIST.contains("minute"))
- - {
- - ret.setFile(htmlPrefix, "data/html/chamberlain/siegetime7.htm");
- - return ret;
- - }
- -
- - return null;
- - }
- -
- private void sendHtmlMessage(L2PcInstance player, String htmlMessage)
- {
- NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- html.setHtml(htmlMessage);
- html.replace("%objectId%", String.valueOf(getObjectId()));
- html.replace("%npcname%", getName());
- + html.replace("%time%", String.valueOf(getCastle().getSiegeDate().getTime()));
- player.sendPacket(html);
- }
- Index: java/com/l2jserver/gameserver/model/entity/Siege.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/Siege.java (revision 343)
- +++ java/com/l2jserver/gameserver/model/entity/Siege.java (working copy)
- @@ -1484,27 +1484,47 @@
- /** Set the date for the next siege. */
- private void setNextSiegeDate()
- {
- - while (getCastle().getSiegeDate().getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
- + // Copy of siege date. All modifications are made on it, then once ended, it is registered.
- + Calendar siegeDate = getCastle().getSiegeDate();
- +
- + // Loop until current time is lower than next siege period.
- + while (siegeDate.getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
- {
- - if ((getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) && (getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY))
- + // If current day is another than Saturday or Sunday, change it accordingly to castle
- + if ((siegeDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) || (siegeDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY))
- {
- - getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
- + switch (getCastle().getCastleId())
- + {
- + case 3:
- + case 4:
- + case 6:
- + case 7:
- + siegeDate.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
- + break;
- +
- + default:
- + siegeDate.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
- + break;
- + }
- }
- - // from CT2.3 Castle sieges are on Sunday, but if server admins allow to set day of the siege
- - // than sieges can occur on Saturdays as well
- - if ((getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) && !Config.CL_SET_SIEGE_TIME_LIST.contains("day"))
- - {
- - getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
- - }
- - // set the next siege day to the next weekend
- - getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
- +
- + // Set next siege date if siege has passed ; add 14 days (2 weeks).
- + siegeDate.add(Calendar.DAY_OF_MONTH, 14);
- }
- - if (!SevenSigns.getInstance().isDateInSealValidPeriod(getCastle().getSiegeDate()))
- + // If the siege date goes on a Seven Signs seal period, add 7 days (1 week).
- + if (!SevenSigns.getInstance().isDateInSealValidPeriod(siegeDate))
- {
- - getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
- + siegeDate.add(Calendar.DAY_OF_MONTH, 7);
- }
- + // Set default hour to 18:00. This can be changed - only once - by the castle leader via the chamberlain.
- + siegeDate.set(Calendar.HOUR_OF_DAY, 18);
- + siegeDate.set(Calendar.MINUTE, 0);
- +
- + // After all modifications are applied on local variable, register the time as siege date of that castle.
- + getCastle().getSiegeDate().setTimeInMillis(siegeDate.getTimeInMillis());
- +
- SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_ANNOUNCED_SIEGE_TIME);
- sm.addCastleId(getCastle().getCastleId());
- Announcements.getInstance().announceToAll(sm);
- Index: java/com/l2jserver/Config.java
- ===================================================================
- --- java/com/l2jserver/Config.java (revision 343)
- +++ java/com/l2jserver/Config.java (working copy)
- @@ -113,7 +113,7 @@
- public static int CS_SUPPORT2_FEE;
- public static int CS_SUPPORT3_FEE;
- public static int CS_SUPPORT4_FEE;
- - public static List<String> CL_SET_SIEGE_TIME_LIST;
- - public static List<Integer> SIEGE_HOUR_LIST_MORNING;
- - public static List<Integer> SIEGE_HOUR_LIST_AFTERNOON;
- // --------------------------------------------------
- // Fortress Settings
- @@ -1569,58 +1566,6 @@
- CH_FRONT2_FEE = Integer.parseInt(Feature.getProperty("ClanHallFrontPlatformFunctionFeeLvl2", "4000"));
- CH_BUFF_FREE = Boolean.parseBoolean(Feature.getProperty("AltClanHallMpBuffFree", "False"));
- - CL_SET_SIEGE_TIME_LIST = new ArrayList<>();
- - SIEGE_HOUR_LIST_MORNING = new ArrayList<>();
- - SIEGE_HOUR_LIST_AFTERNOON = new ArrayList<>();
- - String[] sstl = Feature.getProperty("CLSetSiegeTimeList", "").split(",");
- - if (sstl.length != 0)
- - {
- - boolean isHour = false;
- - for (String st : sstl)
- - {
- - if (st.equalsIgnoreCase("day") || st.equalsIgnoreCase("hour") || st.equalsIgnoreCase("minute"))
- - {
- - if (st.equalsIgnoreCase("hour"))
- - {
- - isHour = true;
- - }
- - CL_SET_SIEGE_TIME_LIST.add(st.toLowerCase());
- - }
- - else
- - {
- - _log.warning(StringUtil.concat("[CLSetSiegeTimeList]: invalid config property -> CLSetSiegeTimeList \"", st, "\""));
- - }
- - }
- - if (isHour)
- - {
- - String[] shl = Feature.getProperty("SiegeHourList", "").split(",");
- - for (String st : shl)
- - {
- - if (!st.equalsIgnoreCase(""))
- - {
- - int val = Integer.parseInt(st);
- - if ((val > 23) || (val < 0))
- - {
- - _log.warning(StringUtil.concat("[SiegeHourList]: invalid config property -> SiegeHourList \"", st, "\""));
- - }
- - else if (val < 12)
- - {
- - SIEGE_HOUR_LIST_MORNING.add(val);
- - }
- - else
- - {
- - val -= 12;
- - SIEGE_HOUR_LIST_AFTERNOON.add(val);
- - }
- - }
- - }
- - if (Config.SIEGE_HOUR_LIST_AFTERNOON.isEmpty() && Config.SIEGE_HOUR_LIST_AFTERNOON.isEmpty())
- - {
- - _log.warning("[SiegeHourList]: invalid config property -> SiegeHourList is empty");
- - CL_SET_SIEGE_TIME_LIST.remove("hour");
- - }
- - }
- - }
- CS_TELE_FEE_RATIO = Long.parseLong(Feature.getProperty("CastleTeleportFunctionFeeRatio", "604800000"));
- CS_TELE1_FEE = Integer.parseInt(Feature.getProperty("CastleTeleportFunctionFeeLvl1", "7000"));
- CS_TELE2_FEE = Integer.parseInt(Feature.getProperty("CastleTeleportFunctionFeeLvl2", "14000"));
- Index: dist/game/data/html/chamberlain/siegetime3.htm
- ===================================================================
- --- dist/game/data/html/chamberlain/siegetime3.htm (revision 894)
- +++ dist/game/data/html/chamberlain/siegetime3.htm (working copy)
- @@ -1,6 +1,9 @@
- <html><body>
- -The current time of siege is %time%.<br>
- -Do you want to change this?<center><br>
- +<font color="LEVEL">[Manage The Next Siege Time]</font><br>
- +The next siege time is %time%.<br>
- +Do you want to change this?<br>
- +<center>
- <a action="bypass -h npc_%objectId%_siege_time_set 0">Yes</a><br>
- -<a action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm">Cancel</a>
- -</center></body></html>
- \ No newline at end of file
- +<button action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm" value="Back" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">
- +</center>
- +</body></html>
- \ No newline at end of file
- Index: dist/game/data/html/chamberlain/siegetime2.htm
- ===================================================================
- --- dist/game/data/html/chamberlain/siegetime2.htm (revision 894)
- +++ dist/game/data/html/chamberlain/siegetime2.htm (working copy)
- @@ -1,4 +1,5 @@
- <html><body>
- -I regret to inform you, my Lord, that the siege battle time cannot be changed once it is set.<center><br>
- -<a action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm">Return</a>
- -</center></body></html>
- \ No newline at end of file
- +<font color="LEVEL">[Manage The Next Siege Time]</font><br>
- +I regret to inform you, my Lord, that the siege battle time cannot be changed once it is set.<br>
- +<center><button action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm" value="Back" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal"></center>
- +</body></html>
- \ No newline at end of file
- Index: dist/game/data/html/chamberlain/siegetime6.htm
- ===================================================================
- --- dist/game/data/html/chamberlain/siegetime6.htm (revision 894)
- +++ dist/game/data/html/chamberlain/siegetime6.htm (working copy)
- @@ -1,5 +1,9 @@
- <html><body>
- -Please set the castle siege time.<center><br><br>
- -%links%<br>
- -<a action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm">Return</a>
- -</center></body></html>
- \ No newline at end of file
- +<font color="LEVEL">[Manage The Next Siege Time]</font><br>
- +Please set the new castle siege time.<br><br>
- +<center>
- +<a action="bypass -h npc_%objectId%_siege_time_set 1 4">4:00 PM</a><br1>
- +<a action="bypass -h npc_%objectId%_siege_time_set 1 8">8:00 PM</a><br>
- +<button action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm" value="Back" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal">
- +</center>
- +</body></html>
- \ No newline at end of file
- Index: dist/game/data/html/chamberlain/siegetime1.htm
- ===================================================================
- --- dist/game/data/html/chamberlain/siegetime1.htm (revision 894)
- +++ dist/game/data/html/chamberlain/siegetime1.htm (working copy)
- @@ -1,4 +1,5 @@
- <html><body>
- -You may not set the time of the castle siege now.<center><br>
- -<a action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm">Return</a><br>
- -</center></body></html>
- \ No newline at end of file
- +<font color="LEVEL">[Manage The Next Siege Time]</font><br>
- +You may not set the time of the castle siege now.<br>
- +<center><button action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm" value="Back" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal"></center>
- +</body></html>
- \ No newline at end of file
- Index: dist/game/data/html/chamberlain/siegetime8.htm
- ===================================================================
- --- dist/game/data/html/chamberlain/siegetime8.htm (revision 894)
- +++ dist/game/data/html/chamberlain/siegetime8.htm (working copy)
- @@ -1,4 +1,5 @@
- <html><body>
- -The siege will commence at %time%.<center><br>
- -<a action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm">Return</a>
- -</center></body></html>
- \ No newline at end of file
- +<font color="LEVEL">[Manage The Next Siege Time]</font><br>
- +The siege will commence at %time%.<br>
- +<center><button action="bypass -h npc_%objectId%_Link chamberlain/chamberlain.htm" value="Back" width=74 height=21 back="L2UI_CH3.Btn1_normalOn" fore="L2UI_CH3.Btn1_normal"></center>
- +</body></html>
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment