Calendar should never be used to get current time.
This commit is contained in:
		| @@ -17,7 +17,6 @@ | ||||
| package org.l2jmobius.gameserver.communitybbs.Manager; | ||||
|  | ||||
| import java.text.DateFormat; | ||||
| import java.util.Calendar; | ||||
| import java.util.Collection; | ||||
| import java.util.Date; | ||||
| import java.util.Map; | ||||
| @@ -87,11 +86,12 @@ public class TopicBBSManager extends BaseBBSManager | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				final long currentTime = System.currentTimeMillis(); | ||||
| 				f.vload(); | ||||
| 				final Topic t = new Topic(TopicConstructorType.CREATE, getInstance().getMaxID(f) + 1, Integer.parseInt(ar2), ar5, Calendar.getInstance().getTimeInMillis(), player.getName(), player.getObjectId(), Topic.MEMO, 0); | ||||
| 				final Topic t = new Topic(TopicConstructorType.CREATE, getInstance().getMaxID(f) + 1, Integer.parseInt(ar2), ar5, currentTime, player.getName(), player.getObjectId(), Topic.MEMO, 0); | ||||
| 				f.addTopic(t); | ||||
| 				getInstance().setMaxID(t.getID(), f); | ||||
| 				final Post p = new Post(player.getName(), player.getObjectId(), Calendar.getInstance().getTimeInMillis(), t.getID(), f.getID(), ar4); | ||||
| 				final Post p = new Post(player.getName(), player.getObjectId(), currentTime, t.getID(), f.getID(), ar4); | ||||
| 				PostBBSManager.getInstance().addPostByTopic(p, t); | ||||
| 				parsecmd("_bbsmemo", player); | ||||
| 			} | ||||
|   | ||||
| @@ -72,15 +72,15 @@ public class Couple | ||||
| 	 | ||||
| 	public Couple(Player player1, Player player2) | ||||
| 	{ | ||||
| 		final int _tempPlayer1Id = player1.getObjectId(); | ||||
| 		final int _tempPlayer2Id = player2.getObjectId(); | ||||
| 		_player1Id = _tempPlayer1Id; | ||||
| 		_player2Id = _tempPlayer2Id; | ||||
| 		final long currentTime = System.currentTimeMillis(); | ||||
| 		_player1Id = player1.getObjectId(); | ||||
| 		_player2Id = player2.getObjectId(); | ||||
| 		 | ||||
| 		_affiancedDate = Calendar.getInstance(); | ||||
| 		_affiancedDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis()); | ||||
| 		_affiancedDate.setTimeInMillis(currentTime); | ||||
| 		 | ||||
| 		_weddingDate = Calendar.getInstance(); | ||||
| 		_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis()); | ||||
| 		_weddingDate.setTimeInMillis(currentTime); | ||||
| 		 | ||||
| 		try (Connection con = DatabaseFactory.getConnection(); | ||||
| 			PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)")) | ||||
|   | ||||
| @@ -559,7 +559,7 @@ public class Duel | ||||
| 	 */ | ||||
| 	public int getRemainingTime() | ||||
| 	{ | ||||
| 		return (int) (_duelEndTime.getTimeInMillis() - Calendar.getInstance().getTimeInMillis()); | ||||
| 		return (int) (_duelEndTime.getTimeInMillis() - System.currentTimeMillis()); | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -192,11 +192,12 @@ public class Olympiad extends ListenersContainer | ||||
| 			_nextWeeklyChange = Long.parseLong(olympiadProperties.getProperty("NextWeeklyChange", "0")); | ||||
| 		} | ||||
| 		 | ||||
| 		final long currentTime = System.currentTimeMillis(); | ||||
| 		switch (_period) | ||||
| 		{ | ||||
| 			case 0: | ||||
| 			{ | ||||
| 				if ((_olympiadEnd == 0) || (_olympiadEnd < Calendar.getInstance().getTimeInMillis())) | ||||
| 				if ((_olympiadEnd == 0) || (_olympiadEnd < currentTime)) | ||||
| 				{ | ||||
| 					setNewOlympiadEnd(); | ||||
| 				} | ||||
| @@ -208,7 +209,7 @@ public class Olympiad extends ListenersContainer | ||||
| 			} | ||||
| 			case 1: | ||||
| 			{ | ||||
| 				if (_validationEnd > Calendar.getInstance().getTimeInMillis()) | ||||
| 				if (_validationEnd > currentTime) | ||||
| 				{ | ||||
| 					loadNoblesRank(); | ||||
| 					_scheduledValdationTask = ThreadPool.schedule(new ValidationEndTask(), getMillisToValidationEnd()); | ||||
| @@ -587,8 +588,8 @@ public class Olympiad extends ListenersContainer | ||||
| 	 | ||||
| 	private long getMillisToOlympiadEnd() | ||||
| 	{ | ||||
| 		// if (_olympiadEnd > Calendar.getInstance().getTimeInMillis()) | ||||
| 		return _olympiadEnd - Calendar.getInstance().getTimeInMillis(); | ||||
| 		// if (_olympiadEnd > System.currentTimeMillis()) | ||||
| 		return _olympiadEnd - System.currentTimeMillis(); | ||||
| 		// return 10; | ||||
| 	} | ||||
| 	 | ||||
| @@ -604,9 +605,10 @@ public class Olympiad extends ListenersContainer | ||||
| 	 | ||||
| 	protected long getMillisToValidationEnd() | ||||
| 	{ | ||||
| 		if (_validationEnd > Calendar.getInstance().getTimeInMillis()) | ||||
| 		final long currentTime = System.currentTimeMillis(); | ||||
| 		if (_validationEnd > currentTime) | ||||
| 		{ | ||||
| 			return _validationEnd - Calendar.getInstance().getTimeInMillis(); | ||||
| 			return _validationEnd - currentTime; | ||||
| 		} | ||||
| 		return 10; | ||||
| 	} | ||||
| @@ -687,14 +689,15 @@ public class Olympiad extends ListenersContainer | ||||
| 	 | ||||
| 	private long getMillisToCompBegin() | ||||
| 	{ | ||||
| 		if ((_compStart.getTimeInMillis() < Calendar.getInstance().getTimeInMillis()) && (_compEnd > Calendar.getInstance().getTimeInMillis())) | ||||
| 		final long currentTime = System.currentTimeMillis(); | ||||
| 		if ((_compStart.getTimeInMillis() < currentTime) && (_compEnd > currentTime)) | ||||
| 		{ | ||||
| 			return 10; | ||||
| 		} | ||||
| 		 | ||||
| 		if (_compStart.getTimeInMillis() > Calendar.getInstance().getTimeInMillis()) | ||||
| 		if (_compStart.getTimeInMillis() > currentTime) | ||||
| 		{ | ||||
| 			return _compStart.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); | ||||
| 			return _compStart.getTimeInMillis() - currentTime; | ||||
| 		} | ||||
| 		 | ||||
| 		return setNewCompBegin(); | ||||
| @@ -752,21 +755,22 @@ public class Olympiad extends ListenersContainer | ||||
| 		 | ||||
| 		LOGGER.info("Olympiad System: New Schedule @ " + _compStart.getTime()); | ||||
| 		 | ||||
| 		return _compStart.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); | ||||
| 		return _compStart.getTimeInMillis() - System.currentTimeMillis(); | ||||
| 	} | ||||
| 	 | ||||
| 	protected long getMillisToCompEnd() | ||||
| 	{ | ||||
| 		// if (_compEnd > Calendar.getInstance().getTimeInMillis()) | ||||
| 		return _compEnd - Calendar.getInstance().getTimeInMillis(); | ||||
| 		// if (_compEnd > System.currentTimeMillis()) | ||||
| 		return _compEnd - System.currentTimeMillis(); | ||||
| 		// return 10; | ||||
| 	} | ||||
| 	 | ||||
| 	private long getMillisToWeekChange() | ||||
| 	{ | ||||
| 		if (_nextWeeklyChange > Calendar.getInstance().getTimeInMillis()) | ||||
| 		final long currentTime = System.currentTimeMillis(); | ||||
| 		if (_nextWeeklyChange > currentTime) | ||||
| 		{ | ||||
| 			return _nextWeeklyChange - Calendar.getInstance().getTimeInMillis(); | ||||
| 			return _nextWeeklyChange - currentTime; | ||||
| 		} | ||||
| 		return 10; | ||||
| 	} | ||||
| @@ -780,7 +784,7 @@ public class Olympiad extends ListenersContainer | ||||
| 			resetWeeklyMatches(); | ||||
| 			LOGGER.info("Olympiad System: Reset weekly matches to nobles"); | ||||
| 			 | ||||
| 			_nextWeeklyChange = Calendar.getInstance().getTimeInMillis() + WEEKLY_PERIOD; | ||||
| 			_nextWeeklyChange = System.currentTimeMillis() + WEEKLY_PERIOD; | ||||
| 		}, getMillisToWeekChange(), WEEKLY_PERIOD); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -825,7 +825,7 @@ public class FortSiege implements Siegable | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		final long delay = getFort().getSiegeDate().getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); | ||||
| 		final long delay = getFort().getSiegeDate().getTimeInMillis() - System.currentTimeMillis(); | ||||
| 		if (delay < 0) | ||||
| 		{ | ||||
| 			// siege time in past | ||||
|   | ||||
| @@ -102,7 +102,7 @@ public class Siege implements Siegable | ||||
| 			 | ||||
| 			try | ||||
| 			{ | ||||
| 				final long timeRemaining = _siegeEndDate.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); | ||||
| 				final long timeRemaining = _siegeEndDate.getTimeInMillis() - System.currentTimeMillis(); | ||||
| 				if (timeRemaining > 3600000) | ||||
| 				{ | ||||
| 					final SystemMessage sm = new SystemMessage(SystemMessageId.S1_HOUR_S_UNTIL_CASTLE_SIEGE_CONCLUSION); | ||||
| @@ -170,9 +170,10 @@ public class Siege implements Siegable | ||||
| 			 | ||||
| 			try | ||||
| 			{ | ||||
| 				final long currentTime = System.currentTimeMillis(); | ||||
| 				if (!_castle.isTimeRegistrationOver()) | ||||
| 				{ | ||||
| 					final long regTimeRemaining = getTimeRegistrationOverDate().getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); | ||||
| 					final long regTimeRemaining = getTimeRegistrationOverDate().getTimeInMillis() - currentTime; | ||||
| 					if (regTimeRemaining > 0) | ||||
| 					{ | ||||
| 						_scheduledStartSiegeTask = ThreadPool.schedule(new ScheduleStartSiegeTask(_castleInst), regTimeRemaining); | ||||
| @@ -181,7 +182,7 @@ public class Siege implements Siegable | ||||
| 					endTimeRegistration(true); | ||||
| 				} | ||||
| 				 | ||||
| 				final long timeRemaining = getSiegeDate().getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); | ||||
| 				final long timeRemaining = getSiegeDate().getTimeInMillis() - currentTime; | ||||
| 				if (timeRemaining > 86400000) | ||||
| 				{ | ||||
| 					_scheduledStartSiegeTask = ThreadPool.schedule(new ScheduleStartSiegeTask(_castleInst), timeRemaining - 86400000); // Prepare task for 24 before siege start to end registration | ||||
| @@ -1235,7 +1236,7 @@ public class Siege implements Siegable | ||||
| 	public void correctSiegeDateTime() | ||||
| 	{ | ||||
| 		boolean corrected = false; | ||||
| 		if (getCastle().getSiegeDate().getTimeInMillis() < Calendar.getInstance().getTimeInMillis()) | ||||
| 		if (getCastle().getSiegeDate().getTimeInMillis() < System.currentTimeMillis()) | ||||
| 		{ | ||||
| 			// Since siege has past reschedule it to the next one | ||||
| 			// This is usually caused by server being down | ||||
| @@ -1346,7 +1347,7 @@ public class Siege implements Siegable | ||||
| 	{ | ||||
| 		setNextSiegeDate(); // Set the next set date for 2 weeks from now | ||||
| 		// Schedule Time registration end | ||||
| 		getTimeRegistrationOverDate().setTimeInMillis(Calendar.getInstance().getTimeInMillis()); | ||||
| 		getTimeRegistrationOverDate().setTimeInMillis(System.currentTimeMillis()); | ||||
| 		_castle.getTimeRegistrationOverDate().add(Calendar.DAY_OF_MONTH, 1); | ||||
| 		_castle.setTimeRegistrationOver(false); | ||||
| 		 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment