Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P core
- diff --git java/config/Olympiad.properties
- index 5c25403..d0c9afb 100644
- --- java/config/Olympiad.properties
- +++ java/config/Olympiad.properties
- @@ -12,40 +12,50 @@
- # Olympiad Battle Period, Default 3 minutes. (If set different, should be < AltOlyBWait)
- AltOlyBattle = 180000
- # Olympiad Battle Wait, Default 10 Minutes
- AltOlyBWait = 600000
- # Olympiad Initial Wait Period, Default 5 minutes
- AltOlyIWait = 300000
- # Olympiad Weekly Period, Default 1 week
- AltOlyWPeriod = 604800000
- # Olympiad Validation Period, Default 24 Hours.
- AltOlyVPeriod = 86400000
- # Required number of participants for Classed and Non-Classed matches, Default 5 & 9
- AltOlyClassedParticipants = 5
- AltOlyNonClassedParticipants = 9
- +#======================================================================================================
- +# Trocar Periodo Olympiadas
- +#======================================================================================================
- +# Voce pode decidir se habilitar o recurso de configurasao de periodo personalizado. Uma vez ativado,
- +# Periodo Alt Oly: MONTH / DAY / WEEK
- +# es. 2 semanas -> AltOlyPeriod = WEEK e AltOlyPeriodMultiplier = 2
- +AltOlyUseCustomPeriodSettings= True
- +AltOlyPeriod = DAY
- +AltOlyPeriodMultiplier = 15
- # Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
- # 0 for displaying digits instead of text phrase (old style).
- # Default: 10
- AltOlyRegistrationDisplayNumber = 10
- # Olympiad battle winner reward for Class and Non_Class games.
- # Retail 6651(Gate Pass)
- AltOlyBattleRewItem = 6651
- # Retail 50 per winning
- AltOlyClassedRewItemCount = 50
- # Retail 30 per winning
- AltOlyNonClassedRewItemCount = 30
- # Olympiad Competition Rewards
- # ItemId for this Reward, Retail 6651(Gate Pass)
- AltOlyCompRewItem = 6651
- # Rate to exchange Points to Reward item, Retail 1 Point * 1000
- AltOlyGPPerPoint = 1000
- # Noblesse points awarded to Heros. Retail 300
- diff --git java/net/sf/l2j/Config.java
- index a600870..0542bc5 100644
- --- java/net/sf/l2j/Config.java
- +++ java/net/sf/l2j/Config.java
- @@ -15,40 +15,41 @@
- package net.sf.l2j;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.math.BigInteger;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Properties;
- import java.util.StringTokenizer;
- import java.util.logging.Logger;
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.base.Experience;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadPeriod;
- import net.sf.l2j.gameserver.util.FloodProtectorConfig;
- import net.sf.l2j.util.StringUtil;
- /**
- * This class contains global server configuration.<br>
- * It has static final fields initialized from configuration files.<br>
- * It's initialized at the very begin of startup, and later JIT will optimize away debug/unused code.
- * @author mkizub
- */
- public final class Config
- {
- private final static Logger _log = Logger.getLogger(Config.class.getName());
- /** Properties file for access level configurations */
- public static final String ACCESS_LEVELS_FILE = "./config/AccessLevels.properties";
- /** Properties file for alternative configurations */
- public static final String ALT_SETTINGS_FILE = "./config/AltSettings.properties";
- /** Properties file for custom configurations */
- public static final String CUSTOM_FILE = "./config/Custom.properties";
- /** Properties file for events configurations */
- @@ -321,40 +322,44 @@
- public static int ALT_CHANNEL_ACTIVATION_COUNT;
- /** Alternative gaming - all new characters always are newbies. */
- public static boolean ALT_GAME_NEW_CHAR_ALWAYS_IS_NEWBIE;
- /** Newbie level range. */
- public static byte ALT_MIN_NEWBIE_LEVEL;
- public static byte ALT_MAX_NEWBIE_LEVEL;
- /** Spell Book needed to learn skill */
- public static boolean SP_BOOK_NEEDED;
- /** Spell Book needet to enchant skill */
- public static boolean ES_SP_BOOK_NEEDED;
- /** Logging Chat Window */
- public static boolean LOG_CHAT;
- /** Logging Item Window */
- public static boolean LOG_ITEMS;
- /** Olympiad Competition Starting time */
- public static int ALT_OLY_START_TIME;
- + public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
- + public static OlympiadPeriod ALT_OLY_PERIOD;
- + public static int ALT_OLY_PERIOD_MULTIPLIER;
- /** Olympiad Minutes */
- public static int ALT_OLY_MIN;
- /** Olympiad Competition Period */
- public static long ALT_OLY_CPERIOD;
- /** Olympiad Battle Period */
- public static long ALT_OLY_BATTLE;
- /** Olympiad Battle Wait */
- public static long ALT_OLY_BWAIT;
- /** Olympiad Inital Wait */
- public static long ALT_OLY_IWAIT;
- /** Olympiad Weekly Period */
- public static long ALT_OLY_WPERIOD;
- /** Olympiad Validation Period */
- public static long ALT_OLY_VPERIOD;
- @@ -1905,41 +1910,43 @@
- RIFT_AUTO_JUMPS_TIME_MAX = Integer.parseInt(altSettings.getProperty("AutoJumpsDelayMax", "600"));
- RIFT_ENTER_COST_RECRUIT = Integer.parseInt(altSettings.getProperty("RecruitCost", "18"));
- RIFT_ENTER_COST_SOLDIER = Integer.parseInt(altSettings.getProperty("SoldierCost", "21"));
- RIFT_ENTER_COST_OFFICER = Integer.parseInt(altSettings.getProperty("OfficerCost", "24"));
- RIFT_ENTER_COST_CAPTAIN = Integer.parseInt(altSettings.getProperty("CaptainCost", "27"));
- RIFT_ENTER_COST_COMMANDER = Integer.parseInt(altSettings.getProperty("CommanderCost", "30"));
- RIFT_ENTER_COST_HERO = Integer.parseInt(altSettings.getProperty("HeroCost", "33"));
- RIFT_BOSS_ROOM_TIME_MULTIPLIER = Float.parseFloat(altSettings.getProperty("BossRoomTimeMultiplier", "1.5"));
- // Olympiad settings
- Properties olympiadSettings = new Properties();
- try (InputStream is = new FileInputStream(new File(OLYMPIAD_FILE)))
- {
- olympiadSettings.load(is);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new Error("Failed to Load " + OLYMPIAD_FILE + " File.");
- }
- + ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Boolean.parseBoolean(olympiadSettings.getProperty("AltOlyUseCustomPeriodSettings", "false"));
- + ALT_OLY_PERIOD = OlympiadPeriod.valueOf(olympiadSettings.getProperty("AltOlyPeriod", "MONTH"));
- + ALT_OLY_PERIOD_MULTIPLIER = Integer.parseInt(olympiadSettings.getProperty("AltOlyPeriodMultiplier", "1"));
- ALT_OLY_START_TIME = Integer.parseInt(olympiadSettings.getProperty("AltOlyStartTime", "20"));
- ALT_OLY_MIN = Integer.parseInt(olympiadSettings.getProperty("AltOlyMin", "00"));
- ALT_OLY_CPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyCPeriod", "14400000"));
- ALT_OLY_BATTLE = Long.parseLong(olympiadSettings.getProperty("AltOlyBattle", "180000"));
- ALT_OLY_BWAIT = Long.parseLong(olympiadSettings.getProperty("AltOlyBWait", "600000"));
- ALT_OLY_IWAIT = Long.parseLong(olympiadSettings.getProperty("AltOlyIWait", "300000"));
- ALT_OLY_WPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyWPeriod", "604800000"));
- ALT_OLY_VPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyVPeriod", "86400000"));
- ALT_OLY_CLASSED = Integer.parseInt(olympiadSettings.getProperty("AltOlyClassedParticipants", "5"));
- ALT_OLY_REG_DISPLAY = Integer.parseInt(olympiadSettings.getProperty("AltOlyRegistrationDisplayNumber","10"));
- ALT_OLY_NONCLASSED = Integer.parseInt(olympiadSettings.getProperty("AltOlyNonClassedParticipants", "9"));
- ALT_OLY_BATTLE_REWARD_ITEM = Integer.parseInt(olympiadSettings.getProperty("AltOlyBattleRewItem", "6651"));
- ALT_OLY_CLASSED_RITEM_C = Integer.parseInt(olympiadSettings.getProperty("AltOlyClassedRewItemCount", "50"));
- ALT_OLY_NONCLASSED_RITEM_C = Integer.parseInt(olympiadSettings.getProperty("AltOlyNonClassedRewItemCount", "30"));
- ALT_OLY_COMP_RITEM = Integer.parseInt(olympiadSettings.getProperty("AltOlyCompRewItem", "6651"));
- ALT_OLY_GP_PER_POINT = Integer.parseInt(olympiadSettings.getProperty("AltOlyGPPerPoint", "1000"));
- ALT_OLY_HERO_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyHeroPoints", "300"));
- ALT_OLY_RANK1_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyRank1Points", "100"));
- ALT_OLY_RANK2_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyRank2Points", "75"));
- ALT_OLY_RANK3_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyRank3Points", "55"));
- diff --git java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
- index 42e27b2..872b93f 100644
- --- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
- +++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
- @@ -700,40 +700,46 @@
- if (_scheduledOlympiadEnd != null)
- _scheduledOlympiadEnd.cancel(true);
- _scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(), 0);
- }
- protected long getMillisToValidationEnd()
- {
- if (_validationEnd > Calendar.getInstance().getTimeInMillis())
- return (_validationEnd - Calendar.getInstance().getTimeInMillis());
- return 10L;
- }
- public boolean isOlympiadEnd()
- {
- return (_period != 0);
- }
- protected void setNewOlympiadEnd()
- {
- + if (Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
- + {
- + setNewOlympiadEndCustom();
- + return;
- + }
- SystemMessage sm = new SystemMessage(SystemMessage.OLYMPIAD_PERIOD_S1_HAS_STARTED);
- sm.addNumber(_currentCycle);
- Announcements.getInstance().announceToAll(sm);
- Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
- Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- scheduleWeeklyChange();
- }
- public byte getCompPeriodState()
- @@ -763,40 +769,46 @@
- _log.info("Olympiad System: New Schedule @ " + _compStart.getTime());
- return (_compStart.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
- }
- protected long getMillisToCompEnd()
- {
- return (_compEnd - Calendar.getInstance().getTimeInMillis());
- }
- private long getMillisToWeekChange()
- {
- if (_nextWeeklyChange > Calendar.getInstance().getTimeInMillis())
- return (_nextWeeklyChange - Calendar.getInstance().getTimeInMillis());
- return 10L;
- }
- private void scheduleWeeklyChange()
- {
- + if (Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
- + {
- + schedulePointsRestoreCustom();
- + return;
- + }
- _scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
- {
- @Override
- public void run()
- {
- addWeeklyPoints();
- _log.info("Olympiad System: Added weekly points to nobles");
- Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- }, getMillisToWeekChange(), WEEKLY_PERIOD);
- }
- protected synchronized void addWeeklyPoints()
- {
- if (_period == 1)
- return;
- for (Integer nobleId : _nobles.keySet())
- @@ -1307,26 +1319,144 @@
- spectator.sendPacket(new ExOlympiadUserInfo(player));
- ExOlympiadSpelledInfo os = new ExOlympiadSpelledInfo(player);
- // Get all player effects
- L2Effect[] effects = player.getAllEffects();
- for (L2Effect e : effects)
- {
- if (e == null || !e.getShowIcon())
- continue;
- if (e.getInUse())
- {
- e.addOlympiadSpelledIcon(os);
- }
- }
- spectator.sendPacket(os);
- }
- }
- + protected void setNewOlympiadEndCustom()
- + {
- + SystemMessage sm = new SystemMessage(SystemMessage.OLYMPIAD_PERIOD_S1_HAS_STARTED);
- + sm.addNumber(_currentCycle);
- +
- + Calendar currentTime = Calendar.getInstance();
- + currentTime.set(Calendar.AM_PM, Calendar.AM);
- + currentTime.set(Calendar.HOUR, 12);
- + currentTime.set(Calendar.MINUTE, 0);
- + currentTime.set(Calendar.SECOND, 0);
- +
- + Calendar nextChange = Calendar.getInstance();
- +
- + switch (Config.ALT_OLY_PERIOD)
- + {
- + case DAY:
- + {
- + currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- + currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
- +
- + if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- + {
- + _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- + }
- + else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- + {
- + _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- + }
- + else
- + {
- + // nothing to do, too low period
- + }
- +
- + }
- + break;
- + case WEEK:
- + {
- + currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- + currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
- +
- + if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- + {
- + _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- + }
- + else
- + {
- + _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- + }
- +
- + }
- + break;
- + case MONTH:
- + {
- + currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- + currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
- +
- + _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- +
- + }
- + break;
- + }
- +
- + _olympiadEnd = currentTime.getTimeInMillis();
- +
- + scheduleWeeklyChange();
- + }
- + private void schedulePointsRestoreCustom()
- + {
- + long final_change_period = WEEKLY_PERIOD;
- +
- + switch (Config.ALT_OLY_PERIOD)
- + {
- + case DAY:
- + {
- +
- + if (Config.ALT_OLY_PERIOD_MULTIPLIER < 10)
- + {
- +
- + final_change_period = WEEKLY_PERIOD / 2;
- +
- + }
- +
- + }
- + break;
- + case WEEK:
- + {
- +
- + if (Config.ALT_OLY_PERIOD_MULTIPLIER == 1)
- + {
- + final_change_period = WEEKLY_PERIOD / 2;
- + }
- +
- + }
- + break;
- + }
- +
- + _scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new OlympiadPointsRestoreTask(final_change_period), getMillisToWeekChange(), final_change_period);
- + }
- + class OlympiadPointsRestoreTask implements Runnable
- + {
- +
- + private long restoreTime;
- +
- + public OlympiadPointsRestoreTask(long restoreTime)
- + {
- + this.restoreTime = restoreTime;
- + }
- +
- + @Override
- + public void run()
- + {
- + addWeeklyPoints();
- + _log.info("Olympiad System: Added points to nobles");
- +
- + Calendar nextChange = Calendar.getInstance();
- + _nextWeeklyChange = nextChange.getTimeInMillis() + restoreTime;
- + }
- +
- + }
- private static class SingletonHolder
- {
- protected static final Olympiad _instance = new Olympiad();
- }
- }
- \ No newline at end of file
- diff --git java/net/sf/l2j/gameserver/model/olympiad/OlympiadPeriod.java
- new file mode 100644
- index 0000000..c3759af
- --- /dev/null
- +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadPeriod.java
- @@ -0,0 +1,6 @@
- +package net.sf.l2j.gameserver.model.olympiad;
- +
- +public enum OlympiadPeriod
- +{
- + MONTH,WEEK,DAY
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement